Skip to content

Support for assigning to this.state inside componentWillReceiveProps - #9040

Merged
acdlite merged 5 commits into
react:masterfrom
acdlite:assignstateincwrp
Feb 22, 2017
Merged

acdlite merged 5 commits into
react:masterfrom
acdlite:assignstateincwrp

Conversation

@acdlite

@acdlite acdlite commented Feb 21, 2017

Copy link
Copy Markdown
Collaborator

We don't explicitly support this pattern, but it happens to work (kinda) in Stack. We'll give it replaceState semantics and print a warning so that people stop relying on this pattern. In the future we'll remove the replaceState behavior but keep the warning.

We don't explicitly support this but it happens to work in Stack. We'll
give it the same semantics as replaceState.
...without dropping the update. This won't work the other way around,
if you assign to this.state before calling setState. we'll add a
deprecation warning so people stop relying on this pattern.
We'll remove support for this in a future release, though we'll likely
still warn.
Tightens up the test a bit to prevent regressions.
@acdlite
acdlite merged commit 42c375b into react:master Feb 22, 2017
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
Support for assigning to this.state inside componentWillReceiveProps
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
Support for assigning to this.state inside componentWillReceiveProps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants