From a62b22aa9515b85ac8080e1efe8ee8f7181d51e4 Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Wed, 13 Jul 2022 15:11:48 -0400 Subject: [PATCH] only perform equality check on connector (#611) * only perform equality check on connector * clarify naming, add comment --- packages/core/src/provider.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/src/provider.tsx b/packages/core/src/provider.tsx index cd6f7a4a3..aa68e8869 100644 --- a/packages/core/src/provider.tsx +++ b/packages/core/src/provider.tsx @@ -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.'