reactNativeReact Native开发经验集React Native开发

ReactNative组件的生命周期

2017-02-22  本文已影响254人  45b645c5912e

初始化阶段

constructor(props) {
  super(props);
  this.state = {
    //key : value
  };
}
componentWillMount() {
}
componentDidMount() {
}

运行阶段

componentWillReceiveProps(nextProps) {
  this.setState({
    //key : value
  });
}
shouldComponentUpdate(nextProps, nextState) {
  return true;
}
componentWillUpdate(nextProps, nextState) {
}
componentDidUpdate(preProps, preState) {
}
render() {
  return(
    <View/>
  );
}

销毁阶段

componentWillUnmount() {
}
上一篇 下一篇

猜你喜欢

热点阅读