Skip to content

Commit d905406

Browse files
committed
doc: mention refreshInterval in the doc
1 parent f0fd2cd commit d905406

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ return (
124124

125125
You can use `EthSWRConfig` to have a global fetcher capable of retrieving basic Ethereum information (e.g. block, getBalance)
126126
or directly interact with a smart contract mapped to its ABI.
127+
To keep the state fresh you can pass `refreshInterval: 30000` to the `value` object so that behind the scene Ether-SWR will refresh every 30 seconds the data of all the keys mounted in the tree components.
127128

128129
```js
129130
import React from 'react'
@@ -201,7 +202,7 @@ export const Wallet = () => {
201202
)}
202203
{active && chainId && (
203204
<EthSWRConfig
204-
value={{ provider: library, ABIs: new Map(ABIs) }}
205+
value={{ provider: library, ABIs: new Map(ABIs), refreshInterval: 30000 }}
205206
>
206207
<EthBalance />
207208
<TokenList chainId={chainId} />

examples/helloworld/src/App.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ export const TokenList = ({ chainId }: { chainId: number }) => {
172172
const { account } = useWeb3React<Web3Provider>()
173173
const tokens = TOKENS_BY_NETWORK[chainId]
174174
// Multiple calls example
175-
const { data: balances } = useEtherSWR<BigNumber[]>(tokens.map(t => [t.address, 'balanceOf', account!]))
175+
const { data: balances } = useEtherSWR<BigNumber[]>(
176+
tokens.map(t => [t.address, 'balanceOf', account!])
177+
)
176178
return (
177179
<>
178180
{balances &&
@@ -207,7 +209,11 @@ export const Wallet = () => {
207209
)}
208210
{active && chainId && (
209211
<EthSWRConfig
210-
value={{ provider: library, ABIs: new Map(ABIs(chainId)) }}
212+
value={{
213+
provider: library,
214+
ABIs: new Map(ABIs(chainId)),
215+
refreshInterval: 30000
216+
}}
211217
>
212218
<EthBalance />
213219
<TokenList chainId={chainId} />

0 commit comments

Comments
 (0)