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

add support for props with nested immutables #3019

Merged
merged 4 commits into from
Jun 9, 2017

Conversation

mattkrick
Copy link
Contributor

Background:
Sometimes, a prop might be a POJO that contains a nested immutable structure. Draft-js' editorState is a great example. Within sCU, the plain deepEqual function is used on it & breaks.

Why this is needed:

  • Per Redux-form compatibility with RichText editor (draft-js) control #2798 the only way to make this work with draft-js is to serialize the editorState.
  • The beauty of immutables is that we don't have to do a deep equals, comparing references is enough
  • folks may use different immutable libraries so there is no safe way to ducktype an immutable
  • folks may have large POJOs that they want to exclude from being deep equaled in sCU. This is a cheap, unobtrusive way to add performance.

Example:
reduxForm({form: 'linkChanger', immutables: ['editorState']})

can bump the docs if you like it

@codecov-io
Copy link

codecov-io commented Jun 5, 2017

Codecov Report

Merging #3019 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #3019   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          67      68    +1     
  Lines        1395    1436   +41     
======================================
+ Hits         1395    1436   +41
Impacted Files Coverage Δ
src/createReduxForm.js 100% <100%> (ø) ⬆️
src/ConnectedField.js 100% <0%> (ø) ⬆️
src/immutable.js 100% <0%> (ø) ⬆️
src/ConnectedFieldArray.js 100% <0%> (ø) ⬆️
src/structure/immutable/keys.js 100% <0%> (ø) ⬆️
src/index.js 100% <0%> (ø) ⬆️
src/createFormValues.js 100% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac33570...fb031bd. Read the comment docs.

@erikras
Copy link
Member

erikras commented Jun 6, 2017

From your description, this sounded like a massive change, and then it only turned out to be two little lines.

So all you're doing is allowing additional "props not to update for" to be specified. It's unclear to me what this has to do with immutability or how it would help with Draft JS. Why are you passing editorState to your form as a prop?

@mattkrick
Copy link
Contributor Author

mattkrick commented Jun 6, 2017 via email

@erikras
Copy link
Member

erikras commented Jun 7, 2017

The problem I see, though, is that you are totally ignoring changes to the props listed. It seems like you should be ===ing them, right?

Let's call it immutableProps.

@mattkrick
Copy link
Contributor Author

you're correct, i was being selfish & just solving for my use case.
Fixed & documented! if a unit test is needed lemme know where.

@erikras
Copy link
Member

erikras commented Jun 8, 2017

Can you get the code coverage back up to 100%?

npm run test:cov
open coverage/lcov-report/index.html

)
TestUtils.Simulate.click(initButton);

// no need to rerender form on initialize
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is kinda misleading, but IMO fix it if you want 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, i was just blindly cut & pasting 😄

@erikras erikras merged commit f985c89 into redux-form:master Jun 9, 2017
@erikras
Copy link
Member

erikras commented Jun 9, 2017

Fantastic!

@mattkrick
Copy link
Contributor Author

oh super duper, thank you!

@erikras
Copy link
Member

erikras commented Jun 9, 2017

Published in v6.8.0.

@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

4 participants