I have a state variable where it is continuously changing and after the final state change I have to call a function which removes duplicate from final state variable.
while I am setting state variable, I am using prevstate to merge the present state value
code is below
const setevent = async(events) =>{
await setevent((prevstate) => [...prevstate,...events])
}
I have to call a function using final event variable as props.
how can I do this?
actually I have seen a approach where after completing the setstate it is like below
const setevent = async(event) =>{
await setevent(event,() => {
//calling the function which I need
getunique(event)
})
}
but I cant make it work because I am already using prevState.
Thanks in advance