组建中的生命周期

2017-01-06  本文已影响0人  夜未殇
//创建属性
constructor(props) {
    super(props);
    console.log("ChildView+constructor")
}

//组建将要加载
componentWillMount() {
    console.log("ChildView+componentWillMount")
}

//渲染开始
render() {
    console.log("ChildView+render")
    return(
        <h3>{this.props.content}</h3>    )
}

//组建加载完成
componentDidMount() {
    console.log("ChildView+componentDidMount")
}

//默认值return true ,只有return true时,UI才能被重新渲染(即重新调用render)
shouldComponentUpdate(nextProps,nestState) {
    console.log("ChildView+shouldComponentUpdate");
    return true;
}

//组建将要刷新
componentWillUpdate(nextProps,nestState) {
    console.log("ChildView+componentWillUpdate");
}

//组建完成刷新
componentDidUpdate(nextProps,nextState) {
    console.log("ChildView+componentDidUpdate");
}

//组件将要接收到新的属性值
componentWillReceiveProps(nextProps) {
    console.log("ChildView+componentWillReceiveProps");
}

//组建将要销毁
componentWillUnmount() {
    console.log("ChildView+componentWillUnmount");
}
上一篇下一篇

猜你喜欢

热点阅读