Skip to content

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