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

feat: throw error if useWallet is being used outside the WalletProvider #125

Merged

Conversation

drichar
Copy link
Collaborator

@drichar drichar commented Dec 15, 2023

Description

If the useWallet hook is being used outside of the React Context provider giving it access to the wallet clients, an error is thrown:

useWallet must be used within the WalletProvider

This also renames the context provider to match the exported WalletProvider module, and the context object itself is returned by the useWalletContext hook.

A warning has been appearing in the console that the default export of zustand/shallow is deprecated, and will be removed in a future release. The named export is used now instead, which will stop the warning from appearing.

Checklist

  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary

This resolves the deprecated warning that started appearing in the console after upgrading to zustand@^4.3.8
This also renames the context provider to match the exported "WalletProvider", and the context object itself is imported via a `useWalletContext` hook.
@drichar drichar changed the title feat: Throw error if useWallet is being used outside the WalletProvider feat: throw error if useWallet is being used outside the WalletProvider Dec 15, 2023
@drichar drichar merged commit 3ccc5e0 into main Dec 15, 2023
1 check passed
@drichar drichar deleted the txn-1560-show-error-if-usewallet-is-being-used-outside-the branch December 15, 2023 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant