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

第171题(2020-03-12):react 哪些生命周期可以 setState? #173

Open
qappleh opened this issue Mar 25, 2020 · 1 comment
Open

第171题(2020-03-12):react 哪些生命周期可以 setState? #173

qappleh opened this issue Mar 25, 2020 · 1 comment

Comments

@qappleh
Copy link
Owner

qappleh commented Mar 25, 2020

No description provided.

@qappleh
Copy link
Owner Author

qappleh commented Jul 3, 2020

生命周期中setState的使用情况:

  • 无意义使用:componentWillMount,componentWillUnmount;

  • 有条件使用:componentDidUpdate;

  • 禁止使用:componentWillUpdate,shouldComponentUpdate;

  • 正常使用:componentWIllReceiveProps,componentDidMount。

生命周期中setState是否触发更新:

    componentWillMount和componentWillReceiveProps中,setState会被react内部处理,而不触发render;

其他生命周期均正常出发更新渲染。

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

No branches or pull requests

1 participant