Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

fix(AutoControlledComponent): fix behaviour when undefined it passed #499

Merged
merged 3 commits into from
Nov 20, 2018

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Nov 20, 2018

We discussed this changes during meetings on the previous week, we need to change the behaviour of AutoControlledComponent to match React's.

An example that shows issue: https://codesandbox.io/s/l20mjn74zz


After this PR we can safely migrate to getDerivedStateFromProps() 👍

@codecov
Copy link

codecov bot commented Nov 20, 2018

Codecov Report

Merging #499 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #499   +/-   ##
=======================================
  Coverage   88.41%   88.41%           
=======================================
  Files          42       42           
  Lines        1450     1450           
  Branches      211      186   -25     
=======================================
  Hits         1282     1282           
  Misses        163      163           
  Partials        5        5

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 28c8307...01a928e. Read the comment docs.

if (!isNextUndefined) acc[prop] = nextProps[prop]
// reinitialize state for props just removed / set undefined
else if (propWasRemoved) acc[prop] = getAutoControlledStateValue(prop, nextProps)
if (isNextDefined) acc[prop] = nextProps[prop]
Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, we don't need to do something with undefined at all. We should update the state only for defined values from props

@layershifter layershifter changed the title [WIP] fix(AutoControlledComponent): fix behaviour when undefined it passed fix(AutoControlledComponent): fix behaviour when undefined it passed Nov 20, 2018
@layershifter layershifter added 🚀 ready for review 🧰 fix Introduces fix for broken behavior. and removed 🚧 WIP labels Nov 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🧰 fix Introduces fix for broken behavior. 🚀 ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants