Skip to content

Commit

Permalink
only perform equality check on connector (Uniswap#611)
Browse files Browse the repository at this point in the history
* only perform equality check on connector

* clarify naming, add comment
  • Loading branch information
NoahZinsmeister authored Jul 13, 2022
1 parent d0def62 commit a62b22a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ export function Web3ReactProvider({
// because we're calling `getPriorityConnector` with these connectors, we need to ensure that they're not changing in place
if (
connectors.length != cachedConnectors.current.length ||
connectors.some((connector, i) => connector !== cachedConnectors.current[i])
connectors.some((connector, i) => {
const cachedConnector = cachedConnectors.current[i]
// because a "connector" is actually an array, we want to be sure to only perform an equality check on the actual Connector
// class instance, to see if they're the same object
return connector[0] !== cachedConnector[0]
})
)
throw new Error(
'The connectors prop passed to Web3ReactProvider must be referentially static. If connectors is changing, try providing a key prop to Web3ReactProvider that changes every time connectors changes.'
Expand Down

0 comments on commit a62b22a

Please sign in to comment.