I have this alert on console:
React Hook useEffect has missing dependencies: 'clearClient', 'clearProductEdit', 'clearProducts', 'client', 'productEdit', and 'rows'. Either include them or remove the dependency array react-hooks/exhaustive-deps
clearClient,ClearProducts and clearProductsEdit are similar functions, which return the initial value of my reducer
The function is working normally, however I would like to resolve this alert, am I using useEffect incorrectly? How can I solve this?
My useEffect:
useEffect(() => {
return () => {
clearClient(client)
clearProducts(rows)
clearProductEdit(productEdit)
}
}, [])
My clearClient function:
function clearClient(c) {
dispatch({
type: 'CLEAR_CLIENT',
payload: { row: c },
})
}
On my reducer,the initialState is:
const initialState = {
client: {
name: '',
id: '',
dateBirth: '',
cpf: '',
address: {
street: '',
number: '',
district: '',
city: '',
cep: '',
uf: '',
complement:'',
phone: '',
},
},
}
And the case of CLEAR_CLIENT:
case 'CLEAR_CLIENT':
return {
...state,
client: {
name: '',
id: '',
dateBirth: '',
cpf: '',
address: {
street: '',
number: '',
district: '',
city: '',
cep: '',
uf: '',
complement:'',
phone: '',
},
},
}