Actually, this is an alternate solution for calling something after setting the state in a functional component. You can use useEffect() more than once.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Prakash, so are you saying we write two effects or use one effect for both the setting of state and calling API?
useEffect(() => {
setFilterObj({ ...props.something});
}, [props.something]);
useEffect(() => {
fetchData(currentPage);
}, [filterObj])
OR
useEffect(() => {
setFilterObj({ ...props.something});
fetchData(currentPage);
}, [props.something, filterObj ]);
Actually, this is an alternate solution for calling something after setting the state in a functional component. You can use useEffect() more than once.