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

fix: added extra condition in isBrowser function #4069

Merged
merged 2 commits into from
Dec 21, 2023

Conversation

ignaciosantise
Copy link
Contributor

@ignaciosantise ignaciosantise commented Dec 20, 2023

Description

  • Added an extra condition to isBrowser function as the current one is not enough for react native.
    • getNavigator returns {"product": "ReactNative"}, and getDocument returns undefined

The origin of the issue is here:

if (!isBrowser()) return;
return localStorage.getItem(key) as string;

because localStorage.getItem is executed in a RN environment

Another option is to change the isBrowser condition to something that also covers react native, such as

if (!isBrowser() || isReactNative()) return;

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Draft PR (breaking/non-breaking change which needs more work for having a proper functionality [Mark this PR as ready to review only when completely ready])
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How has this been tested?

Tested locally in react native

Fixes/Resolves (Optional)

WalletConnect/web3modal-react-native#116

Checklist

  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@ignaciosantise ignaciosantise merged commit d6fe6c1 into v2.0 Dec 21, 2023
9 checks passed
@ignaciosantise ignaciosantise deleted the fix/link-localstorage branch December 21, 2023 11:51
@ganchoradkov ganchoradkov mentioned this pull request Dec 21, 2023
20 tasks
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.

None yet

3 participants