Skip to content
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

Choose getIn based off Iterable.isIterable() #2423

Merged
merged 1 commit into from Jan 12, 2017
Merged

Choose getIn based off Iterable.isIterable() #2423

merged 1 commit into from Jan 12, 2017

Conversation

dxinteractive
Copy link
Contributor

@dxinteractive dxinteractive commented Jan 10, 2017

Currently structure.getIn breaks when using Immutable Records or other keyed Immutable objects that aren't Maps or Lists, because it tries to use the plainGetIn on those.

I've tested this fix in the context of an app I'm working on and these changes work in my case, but haven't verified with any actual tests. By definition all Iterables have getIn so I think it's a low risk change, at least one that's guaranteed to not break any existing desired behaviours with Maps and Lists.

The symptoms are that ConnectedFields are unable to find the field's values in state and value is subsequently passed down as an empty string.

Currently this breaks when using `Record`s or other keyed Immutable objects that aren't `Map`s or `List`s. I've tested this in the context of an app I'm working on and these changes work in my case, but haven't verified with any tests. All `Iterable`s have `getIn` so it's a very low risk change.
@codecov-io
Copy link

codecov-io commented Jan 10, 2017

Current coverage is 100% (diff: 100%)

Merging #2423 into master will not change coverage

@@           master   #2423   diff @@
=====================================
  Files          65      65          
  Lines        1315    1315          
  Methods         0       0          
  Messages        0       0          
  Branches        0       0          
=====================================
  Hits         1315    1315          
  Misses          0       0          
  Partials        0       0          

Powered by Codecov. Last update 3ee630e...f344cd9

@dxinteractive
Copy link
Contributor Author

dxinteractive commented Jan 11, 2017

Ooh, hold off on the pull. This is incomplete, as the equivalent setIn also can't cope with anything other than Map and List items. There's more logic in there that I would have expected, I'll make some tentative changes and update this PR for review.

EDIT: The setIn issue can be sidestepped by ensuring that no creation of Records needs to take place in setIn because they've already been supplied (with blank values) from initialValues. Even better if Records are being used then they can also have default values to prevent the need for setIn to create any.

Happy for this to be merged in again if you all are. Probably needs something added in the docs about using things other than Map and List if so.

@erikras erikras merged commit f6e5b43 into redux-form:master Jan 12, 2017
@erikras
Copy link
Member

erikras commented Jan 12, 2017

Good one. 👍

@erikras
Copy link
Member

erikras commented Jan 26, 2017

Released as v6.5.0.

selvagsz added a commit to selvagsz/redux-form that referenced this pull request Feb 6, 2017
* redux-form/master: (61 commits)
  Exported getFormNames (redux-form#2519)
  v6.5.0
  Do not set FieldArray as touched on submit, as it causes its entry in storeState.fields to become an object instead of an array. The ARRAY_* reducers expects the fields entry to be an array. Fixes redux-form#2014. (redux-form#2473)
  Chore/switch shallowequal to lodash isequalwith (redux-form#2506)
  Keep track of registration count in registeredFields (redux-form#2470)
  fix: when the Field type is "file", value can not be updated (redux-form#2452)
  Remove undocumented name, validate and warn from FieldArray props. (redux-form#2467)
  Clarify what to do when StackOverflow questions get no answers (redux-form#2497)
  Excluded tests from code climate
  Enable Code Climate (redux-form#2486)
  Update ConnectedFields cached handlers when names prop changes. Fixes bug introduced by redux-form#2161. (redux-form#2474)
  Breaking change: Change Fields names instance API to return FormSection prefixed names, to be consistent with Field and FieldArray. (redux-form#2464)
  Add initial value selector (redux-form#2460)
  Add more tests for validateIfNeeded & warnIfNeeded (redux-form#2450)
  Provide validation functions with access to form props (redux-form#2431)
  feat(initialize): add keepSubmitSucceeded option (redux-form#2426)
  Synced Immutable and plain exports (+ tests) (redux-form#2425)
  Choose getIn based off Iterable.isIterable() (redux-form#2423)
  Fixed redux-form#2444 unexpected value updates when radio lose focus (redux-form#2445)
  Beerpay badge
  ...
@lock
Copy link

lock bot commented Jun 1, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants