This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
useConnect: Make connect function undefined until connector is ready (#…
…60) This prevents the `connect` function from being called before `WalletConnectionProps.activeConnector` is ready as the call would then fail. The expectation is that the button/function invoking `connect` checks that doing so is valid. With this change that check is now more direct and less error-prone. This a only barely a breaking change because the expected usage of passing the function to `onClick` of a button keeps working without modification. The difference is that now the click is a noop if the call is invaild instead of an exception being thrown. And checking validity is just the truthiness value of `connect`. In other words you can now just do ```tsx <Button type="button" onClick={connect} disabled={!connect}>Connect</Button> ``` Nice and simple. An alternative solution would be to return an additional boolean `isReadyToConnect`, but that would not allow the type system to prevent the call like it does with this one.
- Loading branch information
Showing
6 changed files
with
46 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters