chore: simplify redux types with ts inference (#1758)
* chore: simplify app dispatch and selector types with ts inference * update SearchModal to use new types inference
This commit is contained in:
parent
d990dfdec7
commit
61d9dfe127
@ -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<AppDispatch>()
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
// user must accept
|
||||
const [confirmed, setConfirmed] = useState(false)
|
||||
|
@ -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<AppState, AppState['lists']['byUrl']>((state) => state.lists.byUrl)
|
||||
const dispatch = useDispatch<AppDispatch>()
|
||||
const listsByUrl = useAppSelector((state) => state.lists.byUrl)
|
||||
const dispatch = useAppDispatch()
|
||||
const { current: list, pendingUpdate: pending } = listsByUrl[listUrl]
|
||||
|
||||
const theme = useTheme()
|
||||
|
5
src/state/hooks.ts
Normal file
5
src/state/hooks.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
|
||||
import { AppDispatch, AppState } from 'state'
|
||||
|
||||
export const useAppDispatch = () => useDispatch<AppDispatch>()
|
||||
export const useAppSelector: TypedUseSelectorHook<AppState> = useSelector
|
Loading…
Reference in New Issue
Block a user