im trying to check the Machine state from inside a function in a react component (state.value), but its never change the current state, it always prints the initial state, but if i put a onClick event in the component and call console.log(state.value), it works... Im doing something wrong?
const [state, send] = useMachine(knightMachine);
const loop = () => {
console.log(state.value);
setTimeout(loop, 10);
}
/// Always print the initial state.
<div
onClick={() => {
console.log(state.value);
}}
></div>
/// It Prints the right value