this is my code:
const handleNotification = React.useCallback(
type => {
setSuccess(type);
setTimeout(() => reset(), 1500);
},
[reset]
);
const sendRequest = React.useCallback(
async () => {
// don't send again while we are sending
if (isSending) return;
// update state
setIsSending(true);
// send the actual request
try {
await axios({
method: "post",
url: NONCOM_SEND_MAIL_URL,
headers: {},
data: {
clientId,
userId,
email,
subject: "Non-Compliant Certificate",
templateCode: "REQNOTMET",
entityId: entity_id
}
});
handleNotification(true);
} catch (e) {
setError(e);
handleNotification(false);
}
// once the request is sent, update state again
if (isMounted.current)
// only update if we are still mounted
setIsSending(false);
},
[isSending, clientId, userId, email, entity_id, handleNotification]
); // update the callback if the state changes
I am getting this warning:
The 'reset' function makes the dependencies of useCallback Hook (at line 35) change on every render. Move it inside the useCallback callback. Alternatively, wrap the 'reset' definition into its own useCallback() Hook
as you can see i have already wrapped it inside useCallback? what did i do wrong in this case? reset is function prop in this component. why does this not work?