-
Notifications
You must be signed in to change notification settings - Fork 129
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
Why I'm getting 2 rendered using this hook, when component mounts? #1061
Comments
because react 18 renders twice in development mode. https://stackoverflow.com/questions/72238175/useeffect-is-running-twice-on-mount-in-react |
can you provide a repro? |
@simoneb I really appreciate your work, and OS software in general. For me, and maybe for you, it's more than a work. So I suggest you not to close an issue after five minutes, making assumptions about other's project/setup. Yes, I maybe a beginner in React but I'm not completely dumb.
|
I see your point, I had assumed React 18 was the cause. I've had a look at your repro and it looks legit. This seems to be causes by an improper handling of the state of the initial request. Would you be interested in submitting a PR to fix this? |
@simoneb thanks but I really can't, my experience with React isn't advanced yet! Hope to see a fix soon (or revert to a previous version maybe?) |
Any update @simoneb ? |
@gremo I didn't have a chance to look into it, but why don't you give it a go? I think it might be pretty simple. If the new state object is the same as the existing, don't change the state :) |
Hello ! For what we have been researching with @Cherrerotinoco It has to be with how the initialState its hanlded with manual false (automatic ), you can prevent this refetching error with |
Plain simple:
The profiler shows 3 renders: first one it's the initial rendering. Second and third are from "Hook 8 changed". Why?
Hook 8 is:
The text was updated successfully, but these errors were encountered: