react component 生命周期
来源:互联网 发布:77kjkj域名访问升级中 编辑:程序博客网 时间:2024/06/05 15:06
过程中涉及三个主要的动作术语:
mounting:表示正在挂接虚拟DOM到真实DOM。updating:表示正在被重新渲染。unmounting:表示正在将虚拟DOM移除真实DOM。
每个动作术语提供两个函数:
componentWillMount() componentDidMount() componentWillUpdate(object nextProps, object nextState) componentDidUpdate(object prevProps, object prevState) componentWillUnmount()
<html> <head> <title>Document</title> <script src="../react.js"></script> <script src="../react-dom.js"></script> <!-- //引用资源,JSX转HTML --> <script src="http://cdn.bootcss.com/babel-core/5.8.38/browser.min.js"></script> </head> <body> <div id="reactContainer"></div> <script type="text/babel"> //babel JSX => HTML const AddCount = React.createClass({ getInitialState: () => { console.log('1.getInitialState') return {count:1} }, componentWillMount: () => console.log('2.componentWillMount'), componentDidMount: () => console.log('3.componentDidMount'), componentWillUpdate: () => console.log('4.componentWillUpdate'), componentDidUpdate: () => console.log('5.componentDidUpdate'), handleClick: function(event) { this.setState({count: ++this.state.count}) }, render: function() { return ( <p> {this.state.count}<br/> <button onClick={this.handleClick}>ADD</button> </p> ) } }) ReactDOM.render( <AddCount/>, document.getElementById('reactContainer') ) </script> </body></html>
阅读全文
1 0
- React Component生命周期
- react native Component 生命周期
- React component 生命周期
- react component 生命周期
- React Native 中 component 生命周期
- React Component Lifecycle(生命周期)
- React Native 中 component 生命周期
- React Native 中 component 生命周期
- React Native 中 component 生命周期
- React Component Lifecycle(生命周期)
- React Native 中 component 生命周期
- React Component 的生命周期 API
- React component lifecycle生命周期管理
- React Native 中 component 生命周期
- React中文教程 - Component Lifecycle(组件的生命周期)
- React Component组件的详细说明和生命周期
- 【React】React.Component小结
- React生命周期
- MyEclipse安装JBPM工作流插件
- Windows解决anaconda下双python版本安装TensorFlow
- ext的排序,根据点击列表列, 对所有数据进行排序, 而不是仅仅对当前页排序
- WPF图片放大缩小
- android手把手教你开发launcher(四)——显示widget
- react component 生命周期
- 文本文档的联通和连通直接保存出现乱码问题
- 字符串处理函数
- android studio 关联 git中国
- 多线程的作用
- git 基本操作
- Split Linked List in Parts问题及解法
- 搭建Nexus Repository 3.6.0-02和配置apache-maven-3.5.2和本地的local Repository以及项目的pom.xml(IDEA 打包等)
- Android | 编译