react-toastify#Flip TypeScript Examples

The following examples show how to use react-toastify#Flip. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: App.tsx    From Account-Manager with MIT License 5 votes vote down vote up
App: FC = () => {
  const dispatch = useDispatch<AppDispatch>();
  const activeBank = useSelector(getActiveBank);
  const activeBankConfig = useSelector(getActiveBankConfig);
  const [getStartedModalIsOpen, toggleGetStartedModal, openGetStartedModal] = useBooleanState(false);
  const [loading, setLoading] = useState<boolean>(true);
  useCrawlSockets();
  useCleanSockets();
  useWebSockets();

  useEffect(() => {
    dispatch(fetchNonDefaultNodeConfigs());
  }, [dispatch]);

  useEffect(() => {
    if (activeBank && !activeBankConfig) {
      setLoading(true);
      const fetchData = async (): Promise<void> => {
        try {
          await dispatch(connect(activeBank));
        } catch (error) {
          displayToast('An error occurred');
        } finally {
          setLoading(false);
        }
      };
      fetchData();
    } else if (!activeBank && !activeBankConfig) {
      setLoading(true);
      const fetchDefaultBankData = async (): Promise<void> => {
        try {
          const response = await dispatch(connectAndStoreLocalData(DEFAULT_BANK, DEFAULT_BANK.ip_address));
          if (response?.error) {
            displayErrorToast(response.error);
            return;
          }
          openGetStartedModal();
        } catch (error) {
          displayToast('An error occurred');
        } finally {
          setLoading(false);
        }
      };
      fetchDefaultBankData();
    } else {
      setLoading(false);
    }
  }, [activeBank, activeBankConfig, dispatch, openGetStartedModal]);

  const renderComponent = (): ReactNode => {
    if (loading) return null;
    if (!activeBank || !activeBankConfig) return <Connect />;
    return <Layout />;
  };

  return (
    <Router>
      {renderComponent()}
      <ToastContainer
        autoClose={3000}
        closeOnClick
        draggable
        hideProgressBar
        newestOnTop
        pauseOnFocusLoss
        pauseOnHover
        position="top-right"
        rtl={false}
        transition={Flip}
      />
      {getStartedModalIsOpen && <CreateAccountModal close={toggleGetStartedModal} isGetStartedModal />}
    </Router>
  );
}