Skip to content

wrapEffect() re-creates effects on every render regardless of new props or not #157

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

Closed
marcusstenbeck opened this issue Nov 1, 2022 · 0 comments · Fixed by #179
Closed

Comments

@marcusstenbeck
Copy link

I think the intended behavior is that it should change whenever the props actually change, but this useMemo will create a new effect instance on every render.

const effect: Effect = useMemo(() => new effectImpl(props), [props])

One solution is to wrap the forwardRef in a React.memo(forwardRef( /*...*/ )) which will do what I believe is the intent with the above line.

@marcusstenbeck marcusstenbeck changed the title All wrapped effect are re-created on every render All wrapEffect()-wrapped effects are re-created on every render Nov 1, 2022
@marcusstenbeck marcusstenbeck changed the title All wrapEffect()-wrapped effects are re-created on every render wrapEffect() re-creates effects on every render regardless of new props or not Nov 1, 2022
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.

1 participant