-
Notifications
You must be signed in to change notification settings - Fork 254
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
feat(clerk-react,remix,nextjs): Make path the default routing strategy for NextJS and Remix #2338
feat(clerk-react,remix,nextjs): Make path the default routing strategy for NextJS and Remix #2338
Conversation
🦋 Changeset detectedLatest commit: 563f1e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 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 |
a5ca7a4
to
d2d8af4
Compare
@octoper I was able to unblock the CI issues, but had to pull work in from |
d2d8af4
to
25ff3f5
Compare
25ff3f5
to
414cbd6
Compare
fdad171
to
0327a81
Compare
import { errorThrower } from '../errors/errorThrower'; | ||
import { noPathProvidedError } from '../errors/messages'; | ||
|
||
export function withPathDefaultRouting<T, P extends RoutingOptions>(Component: T, componentName: string): T { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dimkl Shall we move this to the new react/internal subpath export?
@@ -7,7 +7,7 @@ const OrganizationProfilePage: NextPage = () => { | |||
<div | |||
style={{ display: 'flex', flexDirection: 'column', gap: '2rem', justifyContent: 'center', alignItems: 'center' }} | |||
> | |||
<OrganizationProfile /> | |||
<OrganizationProfile path='/organization' /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Will this error on dev time due to missing type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error will be shown when the component is being rendered. This is a runtime error
} from '@clerk/clerk-react'; | ||
|
||
export const UserProfile: typeof BaseUserProfile = withPathDefaultRouting(BaseUserProfile, 'UserProfile'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job using a HOC for this, but I feel that the types here should just work - why did you need to use typeof
here?
Could it be that the type of the HOC itself needs tweaking so the type can be inferred correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started seeing an error at some point after this PR, that the types couldn't not be inferred automatically.
@@ -37,6 +54,9 @@ export const SignIn = (props: SignInProps) => { | |||
export const SignUp = (props: SignUpProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that you're not using the HOC for the components that are mounted in paths we can infer using the env variables.
I feel like we should align this behavior by either:
- making the Hoc generic enough to support both cases
- supported env variables for all components
Do you want to discuss offline for possible solutions? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I thought about that too, but the path
of <SignIn/>
and <SignUp/>
can be also defined from the Clerk options on the <ClerkProvider/>
and I didn't know if we wanted to make the changes to have ENV and options for every component.
cfe4ca0
to
4da9391
Compare
460354b
to
0a122e4
Compare
6067887
to
c62c439
Compare
<OrganizationProfile routing="hash_or_virtual"/> | ||
<SignIn routing="hash_or_virtual"/> | ||
<SignUp routing="hash_or_virtual"/> | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SokratisVidros , @nikosdouvlis i have also added examples in changeset
c62c439
to
1922a1d
Compare
…useRoutingOptions
This change is applied to show correct component name. Using Component.displayName was causing a `<withClerk(Component)/>` to be shown in error message
1922a1d
to
563f1e7
Compare
Description
This PR introduces changes that will make
path
strategy the default if thepath
prop is filled for Next.js and Remix frameworks, previously the routing strategy if there is norouting
orpath
prop filled we would fallback tohash
routing strategy.In addition if no
path
prop is filled an error will be thrown.Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change
Packages affected
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/clerk-expo
@clerk/fastify
gatsby-plugin-clerk
@clerk/localizations
@clerk/nextjs
@clerk/clerk-react
@clerk/remix
@clerk/clerk-sdk-node
@clerk/shared
@clerk/themes
@clerk/types
build/tooling/chore