This repository was archived by the owner on Apr 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Bad setState call inside Updater #23
Copy link
Copy link
Open
Description
I am receiving an error when attempting to use Multicall Updater similar to the implementation in uniswap-interface
import React from 'react'
import { combineReducers, createStore } from 'redux'
import { createMulticall } from '@uniswap/redux-multicall'
import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from '../constants/chains'
import { useInterfaceMulticall } from '../hooks/useContract'
import useBlockNumber from '../contexts/BlockNumberContext'
const multicall = createMulticall()
const reducer = combineReducers({ [multicall.reducerPath]: multicall.reducer })
export default multicall
function getBlocksPerFetchForChainId(chainId): number {
switch (chainId) {
case SupportedChainId.RINKEBY:
case SupportedChainId.ROPSTEN:
return 5
default:
return 1
}
}
export function MulticallUpdater() {
const { chainId } = useWeb3React()
const latestBlockNumber = useBlockNumber()
const contract = useInterfaceMulticall()
const listenerOptions = React.useMemo(
() => ({
blocksPerFetch: getBlocksPerFetchForChainId(chainId),
}),
[chainId]
)
return (
<multicall.Updater
chainId={chainId}
latestBlockNumber={latestBlockNumber}
contract={contract}
listenerOptions={listenerOptions}
/>
)
} Warning: Cannot update a component (`Updater`) while rendering a different component (`Updater`)
Stack Trace
Warning: Cannot update a component (`Updater`) while rendering a different component (`Updater`). To locate the bad setState() call inside `Updater`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
at Updater
at UpdaterContextBound
at MulticallUpdater
at Updaters
at BlockNumberProvider
at Web3ReactProvider
at UserPreferencesProvider
at Provider
Versions
node v16.8.10
react v18.2.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels