Explorar el Código

fix: dispatch action with effect in next event loop

Fela Maslen hace 4 años
padre
commit
5cfda3593b
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      gmus-web/src/hooks/socket.ts

+ 3 - 1
gmus-web/src/hooks/socket.ts

@@ -43,7 +43,9 @@ export function useDispatchWithEffects(
         localStorage.removeItem(clientNameKey);
       } else {
         setLastAction(action);
-        dispatch(action);
+        setImmediate(() => {
+          dispatch(action);
+        });
       }
     },
     [dispatch, socket],