Skip to content

Commit

Permalink
build: bump react router to v7 (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
pure-js authored Nov 25, 2024
1 parent 7de8ef6 commit a2ce2ee
Show file tree
Hide file tree
Showing 13 changed files with 1,002 additions and 753 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ updates:
- 'react*'
- '@types/react*'
exclude-patterns:
- 'react-router-dom'
- 'react-router'
storybook-group:
patterns:
- 'storybook*'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"dexie-react-hooks": "^1.1.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.15.0",
"react-router": "^7.0.1",
"theme-change": "^2.5.0",
"uuid": "^9.0.0"
},
Expand Down
1,712 changes: 973 additions & 739 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from 'react';
import { Outlet, useLocation } from 'react-router-dom';
import { Outlet, useLocation } from 'react-router';
import { GrowthBook, GrowthBookProvider } from '@growthbook/growthbook-react';

import Header from '~/components/header';
Expand Down
2 changes: 1 addition & 1 deletion src/components/breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMatches } from 'react-router-dom';
import { useMatches } from 'react-router';

import { breadcrumbs, crumb as StCrumb } from './breadcrumbs.css';

Expand Down
2 changes: 1 addition & 1 deletion src/components/header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';
import { themeChange } from 'theme-change';

function Header() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/post-preview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';

import { db } from '~/services/db';

Expand Down
21 changes: 18 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { lazy, StrictMode, Suspense } from 'react';
import { createRoot } from 'react-dom/client';
import { createBrowserRouter, RouterProvider, Link } from 'react-router-dom';
import { createBrowserRouter, Link } from 'react-router';
import { RouterProvider } from 'react-router/dom';

import './index.css';

Expand Down Expand Up @@ -58,7 +59,9 @@ const router = createBrowserRouter(
element: <UserInfo />,
loader: ({ params }) => params,
handle: {
crumb: (data) => <span>{data.userName}</span>,
crumb: (data: { userName: string }) => (
<span>{data.userName}</span>
),
},
},
],
Expand All @@ -72,13 +75,25 @@ const router = createBrowserRouter(
],
{
basename: import.meta.env.BASE_URL,
future: {
v7_relativeSplatPath: true,
v7_fetcherPersist: true,
v7_normalizeFormMethod: true,
v7_partialHydration: true,
v7_skipActionErrorRevalidation: true,
},
},
);

root.render(
<StrictMode>
<Suspense fallback={<>loading...</>}>
<RouterProvider router={router} />
<RouterProvider
router={router}
future={{
v7_startTransition: true,
}}
/>
</Suspense>
</StrictMode>,
);
2 changes: 1 addition & 1 deletion src/pages/[all].tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useLocation } from 'react-router-dom';
import { useLocation } from 'react-router';

function NoMatch() {
const location = useLocation();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/[postId]/edit.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
import { useState } from 'react';
import { redirect, useParams } from 'react-router-dom';
import { redirect, useParams } from 'react-router';
import { useLiveQuery } from 'dexie-react-hooks';

import { db } from '~/services/db';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/[postId]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useNavigate, useParams } from 'react-router-dom';
import { useNavigate, useParams } from 'react-router';
import { useLiveQuery } from 'dexie-react-hooks';

import { db } from '~/services/db';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/new.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type React from 'react';
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router';
import { v4 as uuidv4 } from 'uuid';

import { Input } from '~/components/input';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/users/[user-name].tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useParams } from 'react-router-dom';
import { useParams } from 'react-router';
import { useLiveQuery } from 'dexie-react-hooks';

import { db } from '~/services/db';
Expand Down

0 comments on commit a2ce2ee

Please sign in to comment.