Simple question : if component A declares getInitialState
and uses mixin M that also declares getInitialState
, will both be merged in the "final" component A ?
Use case : I have several forms which share fields and associated state, and I want to avoid code duplication between them, so that each component declares only what's specific to it. I already used mixins in the recent past, but never with state.
Yes, it's possible to merge the state from component A and the state declared in mixin M used by A if the states don't share keys. If they share keys, the Error "Invariant Violation: mergeObjectsWithNoDuplicateKeys()" will be thrown.
PS: using React.js 0.9.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With