Commit 631c202c authored by Justin Domingue's avatar Justin Domingue Committed by GitHub

document `useQueryCacheInvalidator`

explains why `chainId` is pulled directly from the store.
parent 491c9b4f
...@@ -8,9 +8,14 @@ import { useActiveWeb3React } from '../../hooks/web3' ...@@ -8,9 +8,14 @@ import { useActiveWeb3React } from '../../hooks/web3'
import { updateBlockNumber, updateChainId } from './actions' import { updateBlockNumber, updateChainId } from './actions'
function useQueryCacheInvalidator() { function useQueryCacheInvalidator() {
const chainId = useAppSelector((state) => state.application.chainId)
const dispatch = useAppDispatch() 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(() => { useEffect(() => {
dispatch(api.util.invalidateTags([CHAIN_TAG])) dispatch(api.util.invalidateTags([CHAIN_TAG]))
}, [chainId, dispatch]) }, [chainId, dispatch])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment