主要方法:
React.createClass({
//1.初始化state,返回值是个对象
getInitialState: function() {
return {};
},
//2.渲染页面方法,最外面只能有一个标签
render(){
return <div></div>;
},
//3.render方法之前执行,主要用于初始化数据,例如列表初始化发送请求
componentDidMount(){
},
//4.当props的值改变的时候使用,参数为新的props值
componentWillReceiveProps(props){
},
//4.初始化props
getDefaultProps:function(){
}
});
其他方法概要:
1.componentWillMount()
render之前使用
2.componentDidMount()
render之后使用
3.componentWillUpdate(object nextProps, object nextState)
组件更新之前调用
4.componentDidUpdate(object prevProps, object prevState)
组件更新之后调用
5.componentWillUnmount()
移除当前组件的时候使用,一般用于释放内存
6.componentWillReceiveProps(object nextProps)
已加载组件收到新的参数时调用
7.shouldComponentUpdate(object nextProps, object nextState)
组件判断是否重新渲染时调用
React.createClass({
//1.初始化state,返回值是个对象
getInitialState: function() {
return {};
},
//2.渲染页面方法,最外面只能有一个标签
render(){
return <div></div>;
},
//3.render方法之前执行,主要用于初始化数据,例如列表初始化发送请求
componentDidMount(){
},
//4.当props的值改变的时候使用,参数为新的props值
componentWillReceiveProps(props){
},
//4.初始化props
getDefaultProps:function(){
}
});
其他方法概要:
1.componentWillMount()
render之前使用
2.componentDidMount()
render之后使用
3.componentWillUpdate(object nextProps, object nextState)
组件更新之前调用
4.componentDidUpdate(object prevProps, object prevState)
组件更新之后调用
5.componentWillUnmount()
移除当前组件的时候使用,一般用于释放内存
6.componentWillReceiveProps(object nextProps)
已加载组件收到新的参数时调用
7.shouldComponentUpdate(object nextProps, object nextState)
组件判断是否重新渲染时调用