-
Notifications
You must be signed in to change notification settings - Fork 126
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
Question about state in mixins #11
Comments
Well, I know about this behavior, but not sure if it counts as a bug or a normal thing. Here’s what happens:
It’s now a design decision for Rum: assuming we have new component to replace old one of the same class, how do we handle state transition? In some cases we don’t want to lose old state: e.g. We cannot just use new state because it’s not fully initialized yet. Component should go through We cannot just keep old one because in cases like Raw React solves this by keeping old state by default + calling Right now Rum solves it by always replacing old state with new one and providing Both approaches have a downside: we have two code pathes to generate component’s state. In case of Rum, it’s Both approaches lead to unexpected behaviors, subtle bugs when state gets lost (e.g. register listener without de-registering it, leading to listeners leak) and a lot of frustration. I’m still deciding on what’s the best way to solve this is, so expect that this behavior will most probably change. Ideally I would prefer a solution where there’s always single path to component’s state. It should drastically simplify things. Suggestions welcome! |
In some cases rum\react is loosing non-default values in state between
:did-mount
and:will-unmount
hooks in mixin. It doesn't happen if we manually transfer our state in:transfer-state
hook.The following example describes the issue https://gist.github.com/narma/46a990def0e1c6f279a2
In this code errors appear if we use dynamic count of children or we change parent elements.
Errors don't happen if we use constant count of children and don't touch parent elements because
:will-unmount
doesn't fire at all.Is this expected and normal behaviour or is this a bug?
The text was updated successfully, but these errors were encountered: