Swizec / useDimensions

A React Hook to measure DOM nodes
595 stars 45 forks source link

Support for server side rendering #27

Open nishanBende opened 4 years ago

nishanBende commented 4 years ago

We can use a flag named isSSR and use useEffect hook instead of useLayoutEffect. https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85

sorensenjg commented 4 years ago

I second this request! I would like to use this in nextjs.

kevinkashou commented 4 years ago

any update on this?

nishanBende commented 4 years ago

@Swizec I have updated the PR to use typeof window to determine SSR or CSR instead of adding a new flag.

timohermans commented 4 years ago

Any reason why this hasn't been merged yet?

timohermans commented 4 years ago

Also, I've added a comment to the above PR, as the code isn't entirely correct