fix(clerk-js): Replace generic ComponentContext with component-specific contexts - #4486
Merged
Conversation
🦋 Changeset detectedLatest commit: fdcbbed The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
dstaley
marked this pull request as draft
November 5, 2024 01:40
dstaley
marked this pull request as ready for review
November 6, 2024 17:12
dstaley
commented
Nov 6, 2024
| [], | ||
| ); | ||
|
|
||
| if (!context || context.componentName !== 'SignUp') { |
Member
Author
There was a problem hiding this comment.
For simplicity we retain the componentName check. In a future PR we can refactor this out since we always know that we're accessing a value from the expected Context.
alexcarpenter
approved these changes
Nov 6, 2024
jacekradko
reviewed
Nov 6, 2024
Comment on lines
+354
to
359
| const { componentName, ...ctx } = context; | ||
|
|
||
| return { | ||
| ...ctx, | ||
| componentName, | ||
| }; |
Contributor
There was a problem hiding this comment.
Looks like this could be simplified to just
Suggested change
| const { componentName, ...ctx } = context; | |
| return { | |
| ...ctx, | |
| componentName, | |
| }; | |
| return context; |
Member
Author
There was a problem hiding this comment.
yeah this is left over from the previous implementation. When I refactor this to split these contexts into separate files and remove the componentName check I'll clean this up as well!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR replaces the generic
ComponentContextprovider with component-specific versions.The biggest benefit to this PR is reducing the amount of "magic" happening, and moving us towards a more typical approach to handling Context within React applications. Instead of a generic Context that can be one of 11 different types, we now have 11 separate Contexts. This adds a bit more safety in that there won't be an instance where the
SignIncomponent tries to access the Context of another component (which we currently guard against via a runtime check ofcomponentName). Ultimately it's a small change intended to simplify complexity and increase readability.Progress:
SignInSignUpUserProfileUserVerificationUserButtonOrganizationSwitcherOrganizationListOrganizationProfileCreateOrganizationGoogleOneTapWaitlistChecklist
npm testruns as expected.npm run buildruns as expected.Type of change