This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
useConnect: Make connect function undefined until connector is ready #60
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This prevents the
connect
function from being called beforeWalletConnectionProps.activeConnector
is ready as the call would then fail. The expectation is that the button/function invokingconnect
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 ofconnect
. In other words you can now just doNice 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.