Is it possible to put full page width to scrollbar-react?

491 Views Asked by At

I am making a todo app that has a sidebar and a todo page. I would like to make the page height to full screen and not put a fixed height.

Is it possible to do that with simplebar-react?

1

There are 1 best solutions below

0
ishwak sharda On BEST ANSWER

Use useLayoutEffect() in React, the final code for updating should look like this:

const [dimensions, setDimensions] = useState([0, 0]);

useLayoutEffect(() => {
  function updateSize() {
    setDimensions([window.innerWidth, window.innerHeight]);
  }
  window.addEventListener("resize", updateSize);
  updateSize();
  return () => window.removeEventListener("resize", updateSize);
}, []);

and then call dimensions for getting the height and width.