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函数, 有什么方法可以替换它呢?
Pure Function Component (PFC) has no lifecycle. If you need these callbacks, don’t force this.
export default class Test extends React.Component{
componentWillMount(){
}
render(){
}