-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Callback of setState
is called at not expected time.
#556
Comments
Preact folds pre-mount |
What's your opinion? @robertknight Look into this code: https://github.com/developit/preact/blob/master/src/vdom/component.js#L193 Maybe removing the call |
I can confirm this happens in Preact 10: https://codesandbox.io/s/lp5xyqq4vz |
@developit And now, with preact x beta, callback is no more called ! |
Hey @edimitchel, I can confirm that it works in |
I refactor my code and now, the callback is called as expected.. I execute another setState inside the callback (yes, I know, legacy code..), and the callback of this isn't called |
@edimitchel it seems to work here: https://codesandbox.io/s/556-wlfp4 |
@JoviDeCroock Yes, I changed the |
I was talking about this part |
Sorry, I thought it was the same codesandbox url. The render have the right state but not inside the callback.. The first did though.. |
Oh, the state doesn't seem to be updated in the callback but it is in the render, will try to look into it soon. |
I have to create an issue for that ? @JoviDeCroock |
It would be nice to have these separate since this one revolves around |
Given that |
@robertknight |
They're saying "Only the new “UNSAFE_” lifecycle names will work from this point forward.", not "The new “UNSAFE_” lifecycle names will work from this point forward." Which doesn't say they're maintaining it long term, but yes there's no definite plan for fully removing them (there might be some very special use cases where you do want them) Also "these lifecycles will be more likely to have bugs in future versions of React, especially once async rendering is enabled." |
@ForsakenHarmony I suppose it depends on your definition of long-term. The non-prefixed versions will be deprecated after version 16, however "UNSAFE_" will still work and be maintained throughout version 17. No guarantees for version 18 and beyond, however that is a distant future. Should we dismiss the use-case because one day, years down the line, the API may be gone entirely? |
See the following code:
Preact will log:
React will log:
I'm not sure if this is a bug?It will be error when access domNode of child component in callback.
The text was updated successfully, but these errors were encountered: