Skip to content

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

@ms-markda

Description

@ms-markda

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions