[英]React component life cycle: what is difference between render and return and happens after the return?
[英]What is the difference between React component’s phases and React component’s life cycle?
React 组件的阶段和 React 组件的生命周期有什么区别?
基本上所有 React 组件的生命周期方法都可以分为四个阶段:初始化、挂载、更新和卸载。
初始化阶段是我们通过分别实现 getDefaultProps() 和 getInitialState() 为 this.props 和 this.state 定义默认值和初始值的地方。
挂载阶段有两个我们可以使用的方法:componentWillMount() 和 componentDidMount()。
当组件的状态或属性更新时。 生命周期方法是更新阶段的一部分。
卸载阶段包括 componentDidMount()/componentDidUpdate()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.