react 学习--组件的生命周期(二)运行阶段
来源:互联网 发布:c语言需要什么软件 编辑:程序博客网 时间:2024/06/02 12:24
var HelloWorld = React.createClass({ // 1.父组件修改属性触发,可以修改新属性,修改状态 componentWillReceiveProps:function () { console.log("componentWillReceiveProps,1"); }, // 2.返回false会阻止render调用 shouldComponentUpdate:function () { console.log("shouldComponentUpdate,2"); return true; }, // 3.不能修改属性和状态 componentWillUpdate:function () { console.log("componentWillUpate,3"); }, // 4.渲染 render:function () { console.log("render,4"); return ( <p> Hello,{this.props.name?this.props.name:' World'} <span ref="tip"></span> </p> ); }, // 5.完成后可以修改DOM componentDidUpdate:function() { console.log("componentDidUpdate,5"); this.refs.tip.innerHTML += " appened! "; } }); var Test = React.createClass({ getInitialState:function () { return { "name":"" }; }, handleChange:function () { this.setState({ "name":this.refs.myInput.value }); }, render:function () { return( <div> <HelloWorld name={this.state.name}/><br/> <input ref="myInput" type="text" onChange={this.handleChange} /> </div> ); } }); ReactDOM.render(<Test />,document.getElementById("app"));
0 0
- react 学习--组件的生命周期(二)运行阶段
- react 学习--组件的生命周期(一)初始化阶段
- react 学习--组件的生命周期(三)销毁阶段
- React学习(二):组件的生命周期及数据流
- react知识(二) 组件的生命周期【装载过程】
- react学习笔记(2)---组件的生命周期
- react学习笔记 item7 --- 组件的生命周期
- React:组件的生命周期
- React 组件的生命周期
- React组件的生命周期
- React组件的生命周期
- React组件的生命周期
- React组件的生命周期
- React:组件的生命周期
- React组件的生命周期
- React组件的生命周期
- react 组件的生命周期
- React组件的生命周期
- 数据库水平切分的实现原理解析——分库,分表,主从,集群,负载均衡器
- ES-Checker
- oracle中dblink的创建
- 函数_callable(object)
- 分享一款超轻量级数据库访问帮助器 -DbUtility (alias: DataPithy)
- react 学习--组件的生命周期(二)运行阶段
- MySQL MySql连接数与线程池
- 软件测试练习题
- 如何利用百度地图JSAPI画带箭头的线?
- TCP/UDP
- 前端技术面最容易出现的问题?
- UITableView自定义箭头
- linux 命令学习网站
- IOS UITableViewCell常用几种动画效果