Ionic 5 react router cached

Hi,
I am using ionic with react, I have common component which is used on all changes for alerts which will check for redux state and display alerts based on isError true.
but when I move from 1-2 pages alerts is showing that many times as react router will cache it.
how to handle this kind of situation
here is what i am using

  useEffect(() => {
    if (isError) {
        notification(
          {
            show: true,
            message: errorMessage,
            type: 'error',
            autoHide: false,
          }
        );
      }
      dispatch({
        type: CLEAR_ERROR,
      });
    }
  }, [isError]);

need to see more codeā€¦