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

deleteInWithCleanUp needs to check if there is a value in the state before deleting. #2876

Merged
merged 2 commits into from May 4, 2017

Conversation

dagstuan
Copy link
Contributor

@dagstuan dagstuan commented May 3, 2017

This is related to #2875. I'm not sure if this is the best way of fixing the issue, but it solves the problem atleast. Adds a check to see if there is anything in the state before calling deleteIn when deleteInWithCleanUp is called. With this code I no longer get Invalid KeyPath errors when using Immutable.js and editing FieldArrays after submit has failed.

…efore deleting, to avoid Invalid KeyPath errors
@codecov-io
Copy link

codecov-io commented May 3, 2017

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #2876   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          67      68    +1     
  Lines        1395    1400    +5     
======================================
+ Hits         1395    1400    +5
Impacted Files Coverage Δ
src/deleteInWithCleanUp.js 100% <100%> (ø) ⬆️
src/immutable.js 100% <0%> (ø) ⬆️
src/index.js 100% <0%> (ø) ⬆️
src/createAll.js 100% <0%> (ø) ⬆️
src/selectors/getFormMeta.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 de13a80...3b9c219. Read the comment docs.

const result = deleteIn(state, path)

let result = state
if (typeof getIn(state, path) !== 'undefined') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

typeof myvar !== "undefined" is usually only useful for checking if global vars exist - for vars you know exist, use simply myvar !== undefined.

Not a big deal here, though, so no need to bother changing it!

Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal, but I prefer avoiding magic strings whenever possible.

@erikras erikras merged commit f0daf07 into redux-form:master May 4, 2017
erikras pushed a commit that referenced this pull request May 9, 2017
…ializing the form (#2835)

* passing the last initialValues into initialize action if it is reinitializing the form

* Added test related to #2809

* Removed meta.touched from FieldArray props (#2836)

* Add props to the params documented in the field-level validations example (#2855)

* Fix typo in docs/api/Field.md (#2864)

* Improve SubmissionError docs (#2873)

* Add a selector to get touched and visited props from state (#2859)

* added a selector (getFormMeta) which retrieves the form.{$name}.fields slice from state

* added documentation for getFormMeta selector

* Fixed field-level validation reset bug (#2888)

* deleteInWithCleanUp needs to check if there is a value in the state before deleting. (#2876)

* deleteInWithCleanUp needs to check if there is a value in the state before deleting, to avoid Invalid KeyPath errors

* Got rid of string compare

* clean script - added es folder to be rimrafed before build (#2860)

* Add a Field's initial value to props.meta.initial (#2858)

* Add meta.initial to Field props for access to a field’s initial value.

* es6 typo

* add meta.initial to the docs for Field

* Demonstrated that calling onBlur() does not change value #2768

* Better cleanup on UNREGISTER (#2889)

* Checkbox default behavior proposal (#2863)

instead true/false to be true/'' as the current true/false breaks pristine prop

* Fancy new npm5 lock file!

* Allow direct imports to reduce bundle size. (#2893)

* Fix deep equal on maps with different structures (#2892)

* Remove references to react-router from doc page. (#2898)

* Add PropTypes for the Field components (#2862)

* Add PropTypes for the Field components

* Export fieldInputPropTypes, fieldMetaPropTypes and fieldPropTypes

* Merged with changes from #2893

* Exports defaultShouldValidate and defaultShouldAsyncValidate (#2891)

* Exports defaultShouldValidate and defaultShouldAsyncValidate

These default functions are exported for external use - particularly so
that a user can wrap the default functionality with specialised behaviour.

To resolve #2890

* Export default shouldValidates in immutable wrapper

* Allow direct imports to reduce bundle size. (#2893)

* Fix deep equal on maps with different structures (#2892)

* Remove references to react-router from doc page. (#2898)

* Add PropTypes for the Field components (#2862)

* Add PropTypes for the Field components

* Export fieldInputPropTypes, fieldMetaPropTypes and fieldPropTypes

* Merged with changes from #2893
@erikras
Copy link
Member

erikras commented May 9, 2017

Published as v6.7.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