-
Notifications
You must be signed in to change notification settings - Fork 61
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
The component doesn't redraw, but the component function is still executed #97
Comments
Can you put |
When I put console.log in useEffect, it works as I would expect (only the component I change logs anything). I'm not sure I understand, why this is intentional though. I would definitely prefer the unrelated components to not be called at all, not sort of a halfway render :-) |
It's required to avoid so called stale props issue. You don't want some mismatch between props and context value. |
Ok, thanks. |
Seconding this. I just spent quite a long time trying to figure out why my components were re-rendering when using this library because I was using console.log. In my opinion, if possible, the default functionality should 100% be to not call unrelated components. For one, it's confusing when testing the lib, two, because it feels less clean somehow. @dai-shi Fantastic library aside from this. Thank you for all your work in the react state space! |
If we give up concurrent rendering support, it's possible. Without such capability, it's pretty easier to implement an alternative library. FYI, the unexpected behavior is just how useReducer works. https://twitter.com/dai_shi/status/1534170089981100032 |
I haven't played around much with concurrent mode so will reserve an opinion on this. It's a tiny issue with an overall fantastic library, so again, thank you! |
Closing as answered. |
I have tested your minimal example, and when I insert console.log('Counter') in the Counter function and console.log('TextBox') in the TextBox function, all the sub-components log, when I click on a counter button or change a text, even if only the component type where I made the change is actually redrawn (the random number changes).
So the component functions for TextBox are still executed, when I update the Counter and vice versa, even if the result for some reason isn't used by React to actually redraw the Textbox components.
I assume this isn't the intention...?
The text was updated successfully, but these errors were encountered: