facebookarchive / redux-react-hook

React Hook for accessing state and dispatch from a Redux store
MIT License
2.16k stars 103 forks source link

sometime async dispatch will not update by finally #59

Closed xiaoTuiMao closed 5 years ago

xiaoTuiMao commented 5 years ago
const Loading = () => {
  const { requestCount } = useMappedState(state => state.framework);
  const dispatch = useDispatch();
  useEffect(() => {
    dispatch(actions.addRequestCount());
    setTimeout(() => {
      dispatch(actions.subRequestCount());
    }, 10);
  }, []);
  return (
    <div className={cx(styles.container, { [styles.showLoading]: requestCount > 0 })}>
      <img src={loadingIcon} alt="loading" />
    </div>
  );
};

and console in image

work success console image

work fail console image

ianobermiller commented 5 years ago

May you please provide a code pen with a full reproduction? There is too much going on in your example to know what the problem is.

xiaoTuiMao commented 5 years ago

thanks for your reply. i had try again, but I can't reproduce this bug now.