-
Notifications
You must be signed in to change notification settings - Fork 31
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
init-state does not work in mixins #28
Comments
Thanks for reporting & the concrete examples. Yeah, this is related to #25 where The first issue that needs to be resolved is that React expects The second, potentially trickier, issue is how to access/modify this state from mixins; the Hoping to get some time later this week/weekend to dig deeper on this problem, but any help would be appreciated! |
Hmm, this gets even more complicated if you want to support both allowing mixins to add to the components local state (which is what I was trying to do) and to allow them to have their own mixin-local state (as mentioned in #25). How is this handled in plain React? |
In plain React, AFAIK mixins can read/write the same state as component. They are just not allowed to return objects from |
I'm not sure if this is related to #25 or not and its very possible that I'm simply using this wrong (or that its not supported, although the docstrings say that it is). The following test code prints nil instead of "test" as I expect:
Note that "init-state" is printed, so it does get called - the state simply doesn't get merged into the child.
A failed workaround that I tried is to set the state in
will-mount
instead, but this doesn't work because if the component tries to access the state in its own will-mount, this state won't have been set (mixin lifecycle functions seem to get called after the components lifecycle functions).The workaround I eventually went with is less than ideal:
The text was updated successfully, but these errors were encountered: