I am trying to update my reducer every time a useSelector change its value, but I need to use the spread operator to keep the rest of the content of my reducer. But my useEffect gives the following warning:
React Hook useEffect has a missing dependency: 'formValues'. Either include it or remove the dependency array react-hooks/exhaustive-deps.
Is there a way to avoid this warning and keep the rest of state of my reducer?
My code useEffect code:
const handleDispatch = useCallback(
values => {
dispatch(hrRequestHiringFormChangeValues(values));
},
[dispatch]
);
useEffect(() => {
if (cepAddressValues.error !== true) {
handleDispatch({
...formValues,
state: cepAddressValues.state,
city: cepAddressValues.city,
neighborhood: cepAddressValues.neighborhood,
address: cepAddressValues.street,
});
} else {
handleDispatch({
...formValues,
state: '',
city: '',
neighborhood: '',
address: '',
});
}
}, [cepAddressValues, handleDispatch]);