Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nishanBende
Copy link

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)

@nishanBende nishanBende requested a review from Swizec February 5, 2020 05:44
@kevinkashou
Copy link

@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;

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" [...]

Copy link
Author

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

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@magicspon
Copy link

Any news on this getting merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants