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函数, 有什么方法可以替换它呢?
PHP中文网2017-05-19 10:20:58
Pure Function Component (PFC) has no lifecycle. If you need these callbacks, don’t force this.
大家讲道理2017-05-19 10:20:58
export default class Test extends React.Component{
componentWillMount(){
console.log('componentWillMount')
}
render(){
return(
<p>hi</p>
)
}
}