Skip to content

Conversation

wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Sep 3, 2024

Description

This PR makes sure to NOT call browser specific methods (addEventListener, dispatchEvent) implemented in 4059 in non-browser environments. Even though we are trying to block calls by checking window object, it'll still pass because React Native does have some polyfills to the window object.

Fixes SDK-1922

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

changeset-bot bot commented Sep 3, 2024

🦋 Changeset detected

Latest commit: 846c8cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wobsoriano wobsoriano marked this pull request as ready for review September 3, 2024 21:32
};
}

export const injectedWeb3Providers = new InjectedWeb3Providers();
Copy link
Member Author

@wobsoriano wobsoriano Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exporting this makes it global (calling the addEventListener and dispatchEvent methods) and errors out in non-browser environments

@wobsoriano wobsoriano changed the title fix(clerk-js): Ensure we do not access event listener in non-browser environment fix(clerk-js): Ensure we do not access addEventListener and dispatchEvent in non-browser environments Sep 3, 2024
@wobsoriano wobsoriano marked this pull request as draft September 3, 2024 21:51
}

export const injectedWeb3Providers = new InjectedWeb3Providers();
export const getInjectedWeb3Providers = () => InjectedWeb3Providers.getInstance();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exporting it now as a function but making sure it's still instantiated once

@wobsoriano wobsoriano marked this pull request as ready for review September 3, 2024 22:04
Copy link
Member

@brkalow brkalow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏


constructor() {
private constructor() {
if (typeof window === 'undefined') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd that this didn't catch it. Does this mean expo is defining window, but not addEventListener? 😵

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Native is defining window here 🤯

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and looks like expo too

Screenshot 2024-09-03 at 3 10 26 PM

@wobsoriano wobsoriano merged commit f928e4c into main Sep 3, 2024
20 checks passed
@wobsoriano wobsoriano deleted the rob/sdk-1922-clerk-expo-is-throwing-typeerror-windowaddeventlistener-is branch September 3, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants