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

setState in useEffect causes rerender #3

Open
gradyzhu opened this issue Mar 2, 2021 · 2 comments
Open

setState in useEffect causes rerender #3

gradyzhu opened this issue Mar 2, 2021 · 2 comments

Comments

@gradyzhu
Copy link

gradyzhu commented Mar 2, 2021

current behavior:

  • render is called when updater callback is passed to setState in useEffect hook.
  • component renders twice in total

expectation:

  • component is rendered once in total
useEffect(() => {
  setState((state) => {
    const newState = state + 1;
    return newState;
  });
}, [])
@davidmfoley
Copy link
Owner

Hey there -- I'm glad you're finding some use from this. I stopped working on this project in favor of isolate-components and isolate-hooks so I probably won't get a chance to fix this issue, unfortunately.

@gradyzhu
Copy link
Author

gradyzhu commented Mar 2, 2021

appreciate the quick feedback, thanks i'll check it out!

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

No branches or pull requests

2 participants