diff --git a/src/components/SearchModal/ImportList.tsx b/src/components/SearchModal/ImportList.tsx index a0b5e5d546..6248abef81 100644 --- a/src/components/SearchModal/ImportList.tsx +++ b/src/components/SearchModal/ImportList.tsx @@ -14,8 +14,8 @@ import { ExternalLink } from '../../theme/components' import ListLogo from 'components/ListLogo' import { PaddedColumn, Checkbox, TextDot } from './styleds' import { TokenList } from '@uniswap/token-lists' -import { useDispatch } from 'react-redux' -import { AppDispatch } from 'state' + +import { useAppDispatch } from 'state/hooks' import { useFetchListCallback } from 'hooks/useFetchListCallback' import { removeList, enableList } from 'state/lists/actions' import { CurrencyModalView } from './CurrencySearchModal' @@ -37,7 +37,7 @@ interface ImportProps { export function ImportList({ listURL, list, setModalView, onDismiss }: ImportProps) { const theme = useTheme() - const dispatch = useDispatch() + const dispatch = useAppDispatch() // user must accept const [confirmed, setConfirmed] = useState(false) diff --git a/src/components/SearchModal/ManageLists.tsx b/src/components/SearchModal/ManageLists.tsx index 82e6d48b28..8c1d77cfdd 100644 --- a/src/components/SearchModal/ManageLists.tsx +++ b/src/components/SearchModal/ManageLists.tsx @@ -1,8 +1,8 @@ import React, { memo, useCallback, useMemo, useRef, useState, useEffect } from 'react' import { Settings, CheckCircle } from 'react-feather' import ReactGA from 'react-ga' +import { useAppDispatch, useAppSelector } from 'state/hooks' import { usePopper } from 'react-popper' -import { useDispatch, useSelector } from 'react-redux' import styled from 'styled-components/macro' import { useFetchListCallback } from '../../hooks/useFetchListCallback' import { useOnClickOutside } from '../../hooks/useOnClickOutside' @@ -10,7 +10,6 @@ import { TokenList } from '@uniswap/token-lists' import { t, Trans } from '@lingui/macro' import useToggle from '../../hooks/useToggle' -import { AppDispatch, AppState } from '../../state' import { acceptListUpdate, removeList, disableList, enableList } from '../../state/lists/actions' import { useIsListActive, useAllLists, useActiveListUrls } from '../../state/lists/hooks' import { ExternalLink, LinkStyledButton, TYPE, IconWrapper } from '../../theme' @@ -94,8 +93,8 @@ function listUrlRowHTMLId(listUrl: string) { } const ListRow = memo(function ListRow({ listUrl }: { listUrl: string }) { - const listsByUrl = useSelector((state) => state.lists.byUrl) - const dispatch = useDispatch() + const listsByUrl = useAppSelector((state) => state.lists.byUrl) + const dispatch = useAppDispatch() const { current: list, pendingUpdate: pending } = listsByUrl[listUrl] const theme = useTheme() diff --git a/src/state/hooks.ts b/src/state/hooks.ts new file mode 100644 index 0000000000..29062c9855 --- /dev/null +++ b/src/state/hooks.ts @@ -0,0 +1,5 @@ +import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' +import { AppDispatch, AppState } from 'state' + +export const useAppDispatch = () => useDispatch() +export const useAppSelector: TypedUseSelectorHook = useSelector