Fix multiple network setups for React Native SDKs #687
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.
📦 Pull Request
Previously, we were using
await this.checkIsReadyForRequest
before sending a request. Problem is, after first render, this promise will return immediately, even when the relayer is re-rendered. That is because we don't re-construct the controller each time a render happens (that's a no-op).This PR introduces the
isReadyForRequest
boolean which we can reset to false when the relayer is unmounted. That allows us to wait again until the WebView is ready for requests on re-mount.We still keep
checkIsReadyForRequest
because it is used for faster initial requests in browser environments.Before:
https://github.com/magiclabs/magic-js/assets/150072475/7c184022-7938-4a8b-a9ee-c6ac50ee281c
After:
https://github.com/magiclabs/magic-js/assets/150072475/003dcb69-9b1c-41c6-a5bd-1052a9204aca
[Provide a general summary of the pull request here.]
✅ Fixed Issues
Possible issue with Relayer initialization #610
🚨 Test instructions
[Describe any additional context required to test the PR/feature/bug fix.]
Please only add one label:
patch
: Bug Fix?minor
: New Feature?major
: Breaking Change?skip-release
: It's unnecessary to publish this change.📦 Published PR as canary version:
Canary Versions
✨ Test out this PR locally via: