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

ComponentBase: Consider setState(updater) instead of setState(object) #69

Open
ms-markda opened this issue May 8, 2018 · 0 comments
Open

Comments

@ms-markda
Copy link
Collaborator

I don't have evidence that this is hurting us, but the React docs are quite clear that if building state depends on previous state then we should use the updater version instead of the object version. At the ReSub layer, we don't know if the derived class will need this should perhaps we should always opt-in to be safe?

Also, we could forbid using this.state for the previous state since the updater is given prevState (and props). Although that would involve changing the _buildState signature to forward it like the props.

One possible issue: how does the props argument correspond with nextProps in componentWillReceiveProps? Which should we use in there?

https://reactjs.org/docs/react-component.html#setstate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant