Skip to content

Commit

Permalink
💂 ReadonlyNetworksProvider fix refreshing cycle (#843)
Browse files Browse the repository at this point in the history
  • Loading branch information
yivlad committed Jun 24, 2022
1 parent 06cac78 commit d07e0df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-jars-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@usedapp/core': patch
---

Fix refreshing cycle in ReadonlyNetworksProvider
19 changes: 9 additions & 10 deletions packages/core/src/providers/network/readonlyNetworks/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode, useCallback, useEffect, useReducer, useState } from 'react'
import { ReactNode, useCallback, useEffect, useMemo, useReducer, useState } from 'react'
import { providers } from 'ethers'
import { useConfig } from '../../../hooks'
import { Providers } from './model'
Expand Down Expand Up @@ -70,14 +70,13 @@ export function ReadonlyNetworksProvider({ providerOverrides = {}, children }: N
}
}, [providers, getPollingInterval])

return (
<ReadonlyNetworksContext.Provider
value={{
providers,
updateNetworkState: dispatchNetworkState,
}}
>
{children}
</ReadonlyNetworksContext.Provider>
const networks = useMemo(
() => ({
providers,
updateNetworkState: dispatchNetworkState,
}),
[providers, dispatchNetworkState]
)

return <ReadonlyNetworksContext.Provider value={networks}>{children}</ReadonlyNetworksContext.Provider>
}

3 comments on commit d07e0df

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.