Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: downstream referential equality errors #144

Merged
merged 4 commits into from
Aug 15, 2022
Merged

Conversation

NoahZinsmeister
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Aug 12, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
widgets ✅ Ready (Inspect) Visit Preview Aug 15, 2022 at 5:02PM (UTC)

@NoahZinsmeister NoahZinsmeister requested a review from zzmp August 12, 2022 22:30
@vercel vercel bot temporarily deployed to Preview August 12, 2022 22:30 Inactive
@@ -7,7 +7,7 @@ import { Connector, Provider as Eip1193Provider, Web3ReactStore } from '@web3-re
import { WalletConnect } from '@web3-react/walletconnect'
import { SupportedChainId } from 'constants/chains'
import { atom, useAtom } from 'jotai'
import { PropsWithChildren, useEffect, useMemo } from 'react'
import { PropsWithChildren, useEffect, useMemo, useRef } from 'react'
import JsonRpcConnector from 'utils/JsonRpcConnector'

export type Web3Connection = [Connector, Web3ReactHooks]
Copy link
Contributor

Choose a reason for hiding this comment

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

connections is potentially invalid if it changes over time. Does this export need to be reconsidered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so, while i'm still not thrilled about this export, i checked and all the other components that use connections are children of Web3ReactProvider, and since the whole point of this pr is ensuring that this component re-renders whenever connections changes, there shouldn't be any immediate issues

my vote would be to merge this and consider a refactor in a later pr? can make an issue if there's agreement

Copy link
Contributor

Choose a reason for hiding this comment

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

If this is the case, could there just be a hook to expose connections within the React lifecycle? I'm fine with doing this as a follow up, but it seems brittle and not future-proof, so I may just do it today.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tracking in #145

@vercel vercel bot temporarily deployed to Preview August 15, 2022 16:54 Inactive
@vercel vercel bot temporarily deployed to Preview August 15, 2022 17:02 Inactive
@NoahZinsmeister NoahZinsmeister requested a review from zzmp August 15, 2022 17:03
walletConnectConnectionQR,
walletConnectConnectionPopup,
networkConnection,
].filter((connection): connection is Web3Connection => Boolean(connection))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think you can add the type to the template parameters and just use Boolean, so that the actual code remains simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm i tried this and i don't think it's possible - similar issue (without a fix) described here: microsoft/TypeScript#16069

@@ -7,7 +7,7 @@ import { Connector, Provider as Eip1193Provider, Web3ReactStore } from '@web3-re
import { WalletConnect } from '@web3-react/walletconnect'
import { SupportedChainId } from 'constants/chains'
import { atom, useAtom } from 'jotai'
import { PropsWithChildren, useEffect, useMemo } from 'react'
import { PropsWithChildren, useEffect, useMemo, useRef } from 'react'
import JsonRpcConnector from 'utils/JsonRpcConnector'

export type Web3Connection = [Connector, Web3ReactHooks]
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is the case, could there just be a hook to expose connections within the React lifecycle? I'm fine with doing this as a follow up, but it seems brittle and not future-proof, so I may just do it today.

@NoahZinsmeister NoahZinsmeister merged commit efe8d19 into main Aug 15, 2022
@NoahZinsmeister NoahZinsmeister deleted the fix/re-renders2 branch August 15, 2022 17:15
@github-actions
Copy link

🎉 This PR is included in version 2.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants