document useQueryCacheInvalidator

explains why `chainId` is pulled directly from the store.
This commit is contained in:
Justin Domingue 2021-07-29 10:25:29 -07:00 committed by GitHub
parent 491c9b4fd3
commit 631c202c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,8 +8,13 @@ import { useActiveWeb3React } from '../../hooks/web3'
import { updateBlockNumber, updateChainId } from './actions'
function useQueryCacheInvalidator() {
const chainId = useAppSelector((state) => state.application.chainId)
const dispatch = useAppDispatch()
// subscribe to `chainId` changes in the redux store rather than Web3
// this will ensure that when `invalidateTags` is called, the latest
// `chainId` is available in redux to build the subgraph url
const chainId = useAppSelector((state) => state.application.chainId)
useEffect(() => {
dispatch(api.util.invalidateTags([CHAIN_TAG]))