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

No setState(null) #1129

Merged
merged 2 commits into from
Jun 1, 2018
Merged

No setState(null) #1129

merged 2 commits into from
Jun 1, 2018

Conversation

wuweiweiwu
Copy link
Contributor

fixes: #1119

react 15 throws warning when setState is called with null or {}

@wuweiweiwu wuweiweiwu requested a review from TrySound June 1, 2018 08:59
const stateUpdate = {...prevState, needToResetStyleCache: false};
stateUpdate.instanceProps.scrollbarSize = getScrollbarSize();
stateUpdate.instanceProps.scrollbarSizeMeasured = true;
return stateUpdate;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it ok here to mutate state?

Copy link
Contributor Author

@wuweiweiwu wuweiweiwu Jun 1, 2018

Choose a reason for hiding this comment

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

I think so. previously it was this before the gDSFP migration

And since I need to set stuff on instanceProps I use prevState as a base

stateUpdate.needToResetStyleCache = false;
this.setState(stateUpdate);
}
return null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot about this. Will remove

@wuweiweiwu wuweiweiwu merged commit fb68696 into bvaughn:master Jun 1, 2018
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

Successfully merging this pull request may close these issues.

9.19 throws setState(...): You passed an undefined or null state object; instead, use forceUpdate()
2 participants