score:0

  useEffect(() => {
    console.log("context state", JSON.stringify(context.state, null, 2));
    stateRef.current = context.state;
  }, [context.state]);

  useEffect(() => {
    document.onkeypress = function (e) {
      console.log(
        "actual value:", context.state,
        "ref value:", stateRef.current);
      context.dispatch({ type: "KEYPRESS", payload: e.key });
    };
  }, []);


Related Query

More Query from same tag