Search code examples
javascriptreactjsscrollbarsimplebar

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


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?


Solution

  • 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.