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

useIsoLayoutEffect #24

Closed
lxsmnsyc opened this issue Oct 2, 2020 · 1 comment · Fixed by #25
Closed

useIsoLayoutEffect #24

lxsmnsyc opened this issue Oct 2, 2020 · 1 comment · Fixed by #25

Comments

@lxsmnsyc
Copy link

lxsmnsyc commented Oct 2, 2020

Currently, useIsoLayoutEffect is synchronously called in SSR mode, in contrast with how side-effects should never run on SSR mode, infinite re-renders may occur in this case, specially below

useIsoLayoutEffect(() => {
versionRef.current += 1;
setVersion(versionRef.current);
runWithPriority(NormalPriority, () => {
listeners.current.forEach((listener) => {
listener(versionRef.current, value);
});
});
}, [value]);

I think this is an ideal implementation: https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js

@dai-shi
Copy link
Owner

dai-shi commented Oct 2, 2020

Okay, this was intentional and worked pre-v1.2. But, as v1.2 introduced setVersion, it gets crazy... Thanks for the notice.

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 a pull request may close this issue.

2 participants