title: React Hook useEffect has a missing dependency: 'dispatch'
body: <p>This is my first time working with react js , im trying to remove the alert when leaving this view cause i don't want to show it on the other view but in case that there is no error i want to keep the success alert to show it when i'm gonna redirect to the other view</p>
  
  <p>but im getting this wearning on google chrome 
  <code>Line 97:6:   React Hook useEffect has a missing dependency: 'dispatch'. Either include it or remove the dependency array  react-hooks/exhaustive-deps</code></p>
  
  <p>if i did include dispatch i get infinite loop</p>
  
  <pre><code>const [state, dispatch] = useUserStore();
  useEffect(() =&gt; {
      let token = params.params.token;
      checktoken(token, dispatch);
    }, [params.params.token]);
  
    useEffect(() =&gt; {
      return () =&gt; {
        if (state.alert.msg === "Error") {
          dispatch({
            type: REMOVE_ALERT
          });
        }
      };
    }, [state.alert.msg]);
  
  //response from the api
  if (!token_valide || token_valide_message === "done") {
        return &lt;Redirect to="/login" /&gt;;
      }
  </code></pre>
  
  <p>this is useUserStore</p>
  
  <pre><code>  const globalReducers = useCombinedReducers({
      alert: useReducer(alertReducer, alertInitState),
      auth: useReducer(authReducer, authInitState),
      register: useReducer(registerReducer, registerInitState),
      token: useReducer(passeditReducer, tokenvalidationInitState)
    });
    return (
      &lt;appStore.Provider value={globalReducers}&gt;{children}&lt;/appStore.Provider&gt;
    );
  };
  
  export const useUserStore = () =&gt; useContext(appStore);
  </code></pre>