Ensure state is merged into meta props as plain object (#1877, #1955) #2336
+65
−61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cb3abb5 added functionality that merged the state into the meta object for fields. However, when using Immutable JS structures the state will be an Immutable.Iterable. When developing in React Native the
Object.assign
call here cb3abb5#diff-7eb826f425b082db29894569d83899f8R68 causes an exception as described in #1877 and #1955.I am assuming this is because the Object.assign polyfill is different in the React Native environment (any confirmation on this?). I tested the webpack polyfill in the Immutable example and it pretty much just transfers properties from one object to another without any checks. I am assuming this is why this error has not had any more attention since it does not happen in browser environments.
EDIT: Found the polyfill https://github.com/facebook/react-native/blob/master/packager/react-packager/src/Resolver/polyfills/polyfills.js#L56
As for the fix I added a
toJS
method to the structure types. This also means I had to expand the first argument increateFieldProps
andcreateFieldsProps
to be an object instead of justgetIn
. I am not familiar with the code base so any pointers and directions for style is much appreciated. It should be noted that I have not tested this solution in React Native environment (only a dirty hack that accomplishes the same). And I have not tested all the examples either but tests are passing.