It seems you are using hooks. You can't call a function in setState like in class components. You need to watch it through useEffect.
React.useEffect(() => {
updateStatus()
}, [state.id, state.status])
the function created using useState hook doest have a second argument. it will not support call back function after updating the state. it was only there in the setState function which is used in class components.
You can use useEffect instead
useEffect(()=> {
updateStatus()
}, [details])
return (
...
onClick={() => setDetails(prevState => ({...prevState,id: product.orderId,status: 'processing'}))}
...
)
in this way, on every setDetails update it will call useEffect and then updateStatus