Uh oh!
There was an error while loading. Please reload this page.
fix(clerk-react): Handle multiple addListener calls - #4010
Conversation
🦋 Changeset detectedLatest commit: 4eaddcf The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
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 |
addListener callsaddListener calls895e8ea to
7bc89f9Compare| // A separate Map of `addListener` method calls to handle multiple listeners. | ||
| private premountAddListenerCalls = new Map< | ||
| ListenerCallback, | ||
| { | ||
| unsubscribe: UnsubscribeCallback; | ||
| nativeUnsubscribe?: UnsubscribeCallback; | ||
| } | ||
| >(); |
There was a problem hiding this comment.
The reason we want to add a separate map for addListener method calls is that we are already calling addListener internally in our <ClerkContextProvider> component to set the auth state, and I think the current implementation supports only one pre-mount listener (addListener being the unique key to the premountMethodCalls map) and it leads to overwrites/missed events/race condition when addListener is also called at the user level before Clerk is fully loaded.
Description
This PR adds support for multiple
addListenermethod calls without having to wait for Clerk to be loaded.Closes SDK-1552
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change