werkbank
    Preparing search index...

    Function useWindowSize

    • Tracks the window dimensions.

      Returns WindowSize

      An object containing innerHeight and innerWidth.

      This hook listens to the resize event and returns the current innerHeight and innerWidth. It handles server-side rendering by returning 0 initially if window is undefined.

      const { innerWidth, innerHeight } = useWindowSize();
      return <div>Window size: {innerWidth}x{innerHeight}</div>;