-
Notifications
You must be signed in to change notification settings - Fork 541
refactor: upgrade to React 18 + add useAppState
#915
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
refactor: upgrade to React 18 + add useAppState
#915
Conversation
|
Awesome, thanks for this @iamacook! We will review asap. |
|
Hey @iamacook would you consider this a breaking change? I am trying to get a sense of how big a deal it is to force apps to update to v18 of React if they are not already upgraded. It seems like it can be a breaking change in some rare cases with other React libraries from reading the React docs on v18? Ideally we would release this as a minor version update. |
As React 18 is a direct dependency of the package, it shouldn't be a breaking change. However, I'll double-check to be sure and get back to you ASAP. |
|
@aaronbarnardsound, sorry for taking a while to get back to you. I've added the official shim and adjusted the dependencies accordingly. The shim ( |
|
@aaronbarnardsound Can this be prioritized? Currently, the package won't work with React 18 because of strict peerDependancies. |
|
@ChristopherWirtOfficial Yes this should be merged shortly and is currently in review! |
|
Hi @iamacook,
Did you test the PR changes with a react app with web3-onboard installed?
Thanks. |
|
Hi @mahmud-bn, thanks for testing! I didn't extensively cover legacy React versions so I missed the shim issue. I've now realigned my code with the currently deployed version of I've also tested my changes in a fresh React project which included the following
After builing my PR and replacing
I hope all is now working correctly. |
|
Hi @iamacook, this has been merged. Thanks for making this PR and making subsequent changes. |

Description
This PR simplifies state subscription by using React 18 and the new
useSyncExternalStorehook, as well as a few small tweaks.useAppStatehook has been added. It's possible to subscribe to the entire state or part of it via its argument, just as one would with theselect()method.connect()method has been made optional to match that ofconnectWallet().web3Onboardinstance directly.I haven't altered the version number as I'm not sure how you guys would like to approach that seeing as it includes a substantial dependency upgrade.
Checklist
package.jsonis incremented following semantic versioning