-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This PR enables SSR support #28
base: master
Are you sure you want to change the base?
Conversation
@Swizec - Can we please get this merge in? |
src/index.ts
Outdated
}: UseDimensionsArgs = {}): UseDimensionsHook { | ||
const [dimensions, setDimensions] = useState({}); | ||
const [node, setNode] = useState(null); | ||
|
||
const useLayoutHookBasedOnEnvironment = typeof window === undefined ? useEffect : useLayoutEffect; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to let you know this code won't work, because typeof will always return a string. This works:
typeof window === "undefined" [...]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. My bad. Fixed it. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree this would be nice to get merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Any news on this getting merged? |
Allow passing a flag named enableSSR and use useEffect instead of useLayoutEffect when enableSSR is true.
Referred gist - https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
Related issue:
#27 (comment)