【发布时间】:2020-01-19 18:33:43
【问题描述】:
我想做一个 useEffect 方法,当任何 props 改变时调用,但不是所有代码,只是一个专用于这个 props 的代码
我想像这样的事情...... 在这一刻,当一、二或三发生变化时,所有的代码都会被调用。
const SomethingComponent = (props: any) => {
const {one, two, three} = props;
useEffect(() => {
if(something for one props){
code for one
}
if(something for two props){
code for two
}
if(something for three props){
code for three
}
}, [one, two, three]);
}
【问题讨论】:
标签: reactjs react-hooks use-effect