javascript - What should I use to replace the componentWillMount life cycle function?
天蓬老师
天蓬老师 2017-05-19 10:18:58
0
2
636

How can we replace the previous componentWillMount function with the current functional writing method?

const demo = ()=> { 
  const hi = ()=>{
    console.log('say hi');
  }
  
  return ( <p>hi</p> );
};
export default demo;

那么现在我想用componentWillMount函数, 有什么方法可以替换它呢?
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
洪涛

Pure Function Component (PFC) has no lifecycle. If you need these callbacks, don’t force this.

大家讲道理

export default class Test extends React.Component{

componentWillMount(){

console.log('componentWillMount')

}

render(){

return(
  <p>hi</p>
)
  }

}

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template