Update docs and tests to use latest react fiber best practices for this.setState#8
Closed
ekeric13 wants to merge 3 commits intojamiebuilds:masterfrom
ekeric13:master
Closed
Update docs and tests to use latest react fiber best practices for this.setState#8ekeric13 wants to merge 3 commits intojamiebuilds:masterfrom ekeric13:master
ekeric13 wants to merge 3 commits intojamiebuilds:masterfrom
ekeric13:master
Conversation
Andarist
reviewed
Feb 2, 2018
|
|
||
| increment() { | ||
| this.setState({ count: this.state.count + 1 }); | ||
| this.setState((prevState) => ({ count: prevState.count + 1 })); |
Collaborator
There was a problem hiding this comment.
Cotainers are not React.Components, while they have same-ish setState method, it doesnt event yet allow callback-style argument - see #1
Andarist
reviewed
Feb 2, 2018
| state = { count: 0 }; | ||
| increment = () => { | ||
| this.setState({ count: this.state.count + 1 }); | ||
| this.setState((prevState) => ({ count: prevState.count + 1 })); |
Collaborator
There was a problem hiding this comment.
sam here, this setState method doesn't accept callback style
Collaborator
|
I feel like this change is really unnecessary at this point of time, this callback-style is also not related to React Fiber itself - you can use callback-style |
Owner
|
What we have now is fine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this.setStatenow has an updater function that lets you avoid mutating state: https://reactjs.org/docs/react-component.html#setstateaka:
Just made changes where I saw it being used incorrectly to keep up with best practices.