Skip to content
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

React Router v6 beta 6 #481

Merged
merged 1 commit into from
Oct 15, 2021
Merged

React Router v6 beta 6 #481

merged 1 commit into from
Oct 15, 2021

Conversation

david-crespo
Copy link
Collaborator

@david-crespo david-crespo commented Oct 15, 2021

Only small changes needed because of #465. I've had this change cooking since before I was on leave, just want to wrap it up. v6 should be coming out of beta in the next week or two:

There are just two more changes we need to make before hitting v6 stable.

• Fix "linking up" with relative
• Back out the blocking features. We will revisit adding these post-6.0

You can read more about the first issue here
remix-run/react-router#8086
(tweet 10/7)

The release of React Router v6 is imminent. One more beta, then we'll go stable. 👍
tweet 10/14)

We're not using relative links "up" the route tree or useBlocker (which they're apparently taking out) so we should be pretty much good for v6 stable after this.

@vercel
Copy link

vercel bot commented Oct 15, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/oxidecomputer/console-ui-storybook/2tVbbP9Vv37aKQNSYw2kVukL9sgt
✅ Preview: https://console-ui-storybook-git-react-router-v6-beta6-oxidecomputer.vercel.app

@@ -28,20 +28,20 @@ const App = () => (
<Router>
<QuickMenu />
<Routes>
<Route path="/" element={<Navigate to="/projects" replace={true} />} />
<Route index element={<Navigate to="/projects" replace={true} />} />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

they added this index thing because of changes to the handling of absolute paths. I like it a lot better than path="/" anyway.

If you were using <Route path="/"> to indicate an index route, you can now use the new <Route index> prop to accomplish the same thing. The index prop makes it easy to scan a route config to find the index route. It also provides a guarantee that nobody will ever add children to that route.

https://github.com/remix-run/react-router/releases/tag/v6.0.0-beta.4

<Route path="new" element={<ProjectCreatePage />} />
</Route>

{/* PROJECT */}
<Route path="/projects/:projectName" element={<ProjectLayout />}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this leading slash was fine but not necessary. plus once we nest this all under /orgs/cyberdyne it would have been necessary to remove it

@@ -31,9 +31,11 @@ const projectPaths: Record<string, (s: string) => string> = {
'Project access': (projectName) => `/projects/${projectName}/access`,
}

// can't use useParams because QuickMenu is not rendered inside the route tree, so
// it does not have access to the current route
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

had to re-learn the hard way why I did this. next time I will not have to

Copy link
Contributor

@zephraph zephraph Oct 15, 2021

Choose a reason for hiding this comment

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

Future me will likely thank you for this too

@david-crespo david-crespo temporarily deployed to Preview VM October 15, 2021 16:34 Inactive
@@ -46,8 +47,12 @@ export const NavLinkItem = (props: {
<li>
<NavLink
to={props.to}
className="flex items-center p-1 hover:bg-gray-400 svg:mr-2 svg:text-gray-300"
activeClassName="text-white svg:!text-green-500"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

This seemed like an odd API choice at first but it makes sense after looking at the root issue that inspired it: remix-run/react-router#7194. It's particularly helpful in our case given that we're using tailwind and could run afoul of that issue.

Base automatically changed from invariant to main October 15, 2021 17:18
@github-actions
Copy link
Contributor

Preview will be deployed at https://console-git-react-router-v6-beta6.internal.oxide.computer

@@ -21,7 +21,6 @@ const ProjectList = (props: { className?: string }) => {
<NavLink
className="inline-flex w-full p-1"
to={`/projects/${p.name}`}
activeClassName="text-white"
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this just not needed or does it still need to be converted over?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No longer needed because we never stay on the org layout after a project has been selected.

@zephraph
Copy link
Contributor

Refreshingly straight forward. The only proper question I have is about the activeClassName removal.

@david-crespo david-crespo merged commit 94534fd into main Oct 15, 2021
@david-crespo david-crespo deleted the react-router-v6-beta6 branch October 15, 2021 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants