-
Notifications
You must be signed in to change notification settings - Fork 23
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
Support React Router v6 #32
Conversation
this is fantastic, thanks @Grapedge ! I'll review it today, but on initial glance it looks great |
const splatPenalty = -2; | ||
const isSplat = (s: string) => s === '*'; | ||
|
||
function computeScore(path: string, index: boolean | undefined): number { |
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's great that we're now using the same route weight strategy in react-router 6, but my only concern is that we'll have to keep a close eye on if they change that strategy in later versions.
That said, there's not much we can do about it if they're not exporting this scoring method.
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.
Looks good so far - could you also bump version
in package.json
to 3.0.0
?
... I know I should have a script do this automatically, but haven't implemented yet - thanks!
Yes, I read the source code of react router, and I don't think we have a stable way to do this for the time being.
I have changed the version to 3.0.0 😊 |
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.
LGTM.
Support React Router v6: #31
What are the changes?
matchOptions
.How to migrate
Change Route Config to Route Object:
Think about how to deal with matchOptions, In React Router v6, we have no concept of strict or exact matching, so you can only configure
caseSensitive
in the route object:Try to use nested relative paths, otherwise your route-objects may be difficult to maintain:
match.url
has been replaced bymatch.pathname
, see matchPath, It is also recommended to just usematch.params
andmatch.pathname
:There may be other things that need attention, but I’m sorry I can only think of these for the time being.
Code Review
This change may be relatively large, and some things may require more careful consideration. For formal use, more detailed testing may be required.
Regarding why
matchRoutes
is not used, I mainly considered the following two points: