I often have a use case where there is some state in reducer and it needs to be accessed in some callback (useCallback) as well
const [state, dispatch] = useReducer(reducer, initialState);
...
const handleAction = useCallback(()=>{
// dependency on state
},[])
to avoid running useCallbacks on every state change, I reach out for a ref and have the state assigned to it on every render
stateRef.current = state;
and then where ever i have to use something from state in a callback, it is accessed from the stateRef. Is this a right way of doing it?