i wonder how using useEffect like componentWillReceiveProps.
i'm using redux in my react app.
So i have a some redux state when it state updated i wan't to execute some function in my component. When i use class components i did it like that:
componentWillReceiveProps(nextProps) {
if (nextProps.Reducer.complete !== this.props.Reducer.complete) {
someFunc();
}
}
Now i'm using just functional components and hooks.
now my component is like that: I'm trying to do it with this way but not working. Any idea where i mistaken ?
function Component(props) {
const Reducer = useSelector(state => state.Reducer);
const someFunc = () => {
.....
}
useEffect(() => {
someFunc();
}, [Reducer.complete]);
}
export default Component;