I'm replacing lifecycle methods in class based component into useEffecthooks since I'm into functional component. I'm not sure I'm using useEffect properly..
we can't point previous state or props in useEffect, how can I deal with these with useEffect?
Let's say we have props named src, and I want to check if this src has changed, If not, there would be some logic for it.
componentDidUpdate(prevProps) {
const { src } = this.props;
if(prevProps.src !== src) {
this.cleanUp();
this.init();
} else{
// todo something
}
}
how can I deal with this using useEffect?