Skip to content

Commit

Permalink
Update routing library from react-router-dom to react-router
Browse files Browse the repository at this point in the history
- Updated package.json to replace react-router-dom with react-router version 7.0.1.
- Refactored imports across the codebase
  • Loading branch information
ryota-murakami committed Dec 1, 2024
1 parent de07fde commit d79f27d
Show file tree
Hide file tree
Showing 38 changed files with 75 additions and 70 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"react-hook-form": "^7.53.2",
"react-markdown": "^9.0.1",
"react-redux": "9.1.2",
"react-router-dom": "^6.28.0",
"react-router": "^7.0.1",
"react-spinners": "^0.14.1",
"redux": "5.0.1",
"redux-persist": "^6.0.0",
Expand Down
65 changes: 35 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Suspense, memo } from 'react'
import { Provider as ReduxStoreProvider } from 'react-redux'
import { BrowserRouter } from 'react-router-dom'
import { BrowserRouter } from 'react-router'
import { persistStore } from 'redux-persist'
import { PersistGate as ReduxPersistGate } from 'redux-persist/integration/react'

Expand Down
2 changes: 1 addition & 1 deletion src/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { memo } from 'react'
import { Routes as ReactRouterRoutes, Route } from 'react-router-dom'
import { Routes as ReactRouterRoutes, Route } from 'react-router'

import About from './pages/About'
import Dashboard from './pages/Dashboard'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Header.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BrowserRouter } from 'react-router-dom'
import { BrowserRouter } from 'react-router'

import Header from './Header'

Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { memo } from 'react'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'

import Github from '../icons/Github'
import ThemeToggle from '../ToggleTheme'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Layout.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BrowserRouter } from 'react-router-dom'
import { BrowserRouter } from 'react-router'

import Layout from '.'

Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/CreateLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PlusIcon } from '@heroicons/react/24/outline'
import React, { memo } from 'react'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'

import { onCloseHander } from './onCloseHander'

Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/DashboardLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HomeIcon } from '@heroicons/react/24/outline'
import React, { memo } from 'react'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'

import { onCloseHander } from './onCloseHander'

Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/LoginLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArrowLeftOnRectangleIcon } from '@heroicons/react/24/outline'
import React, { memo } from 'react'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'

import { onCloseHander } from './onCloseHander'

Expand Down
4 changes: 2 additions & 2 deletions src/components/Sidebar/LogoutLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ArrowRightOnRectangleIcon } from '@heroicons/react/24/outline'
import React, { memo } from 'react'
import type { NavigateFunction } from 'react-router-dom'
import { useNavigate } from 'react-router-dom'
import type { NavigateFunction } from 'react-router'
import { useNavigate } from 'react-router'

import { logout } from '../../redux/adminSlice'
import { API } from '../../redux/API'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/SettingLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CogIcon } from '@heroicons/react/24/outline'
import React, { memo } from 'react'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'

import { onCloseHander } from './onCloseHander'

Expand Down
4 changes: 2 additions & 2 deletions src/lib/TestRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { render } from '@testing-library/react'
import type { ReactElement } from 'react'
import React from 'react'
import { Provider } from 'react-redux'
import type { MemoryRouterProps } from 'react-router-dom'
import { MemoryRouter } from 'react-router-dom'
import type { MemoryRouterProps } from 'react-router'
import { MemoryRouter } from 'react-router'

import { store } from '../redux/store'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/About/About.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BrowserRouter } from 'react-router-dom'
import { BrowserRouter } from 'react-router'

import About from '.'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Create/Create.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BrowserRouter } from 'react-router-dom'
import { BrowserRouter } from 'react-router'

import Create from '.'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Create/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChangeEvent } from 'react'
import type { NavigateFunction } from 'react-router-dom'
import type { NavigateFunction } from 'react-router'

import type { AdminState } from '../../../redux/adminSlice'
import type { API } from '../../../redux/API'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Create/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { superstructResolver } from '@hookform/resolvers/superstruct'
import React, { memo } from 'react'
import { useForm } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import Button from '@/src/components/Button'
import Input from '@/src/components/Input/Input'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Dashboard.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BrowserRouter } from 'react-router-dom'
import { BrowserRouter } from 'react-router'

import Dashboard from '.'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Edit/Edit.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import { MemoryRouter, Routes, Route } from 'react-router-dom'
import { MemoryRouter, Routes, Route } from 'react-router'

import Edit from '.'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Edit/Edit.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { waitFor } from '@testing-library/dom'
import React from 'react'
import { Routes, Route } from 'react-router-dom'
import { Routes, Route } from 'react-router'

import { sleep } from '../../../../lib/sleep'
import TestRenderer from '../../../lib/TestRenderer'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Edit/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { UseFormGetValues } from 'react-hook-form'
import type { NavigateFunction } from 'react-router-dom'
import type { NavigateFunction } from 'react-router'

import type { AdminState } from '../../../redux/adminSlice'
import type { FormInput } from '../../../redux/draftSlice'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Edit/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { superstructResolver } from '@hookform/resolvers/superstruct'
import React, { memo } from 'react'
import { useForm } from 'react-hook-form'
import { useParams, useNavigate } from 'react-router-dom'
import { useParams, useNavigate } from 'react-router'

import Button from '@/src/components/Button'
import Input from '@/src/components/Input/Input'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/EditButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { memo } from 'react'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'

import Button from '@/src/components/Button'
import type { UsePagenationResult } from '@/src/components/Pagination/usePagination'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import clsx from 'clsx'
import React, { memo } from 'react'
import type { ComponentProps } from 'react'
import { Link, Routes, Route, Outlet, useLocation } from 'react-router-dom'
import { Link, Routes, Route, Outlet, useLocation } from 'react-router'

import Layout from '@/src/components/Layout'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { memo } from 'react'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'

import Button from '@/src/components/Button'
import Layout from '@/src/components/Layout'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Index/Index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BrowserRouter } from 'react-router-dom'
import { BrowserRouter } from 'react-router'

import Index from '.'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Index/PostList/PostRow/PostLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { memo } from 'react'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'

interface Props {
index: number
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Login/Login.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BrowserRouter } from 'react-router-dom'
import { BrowserRouter } from 'react-router'

import Login from '.'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { superstructResolver } from '@hookform/resolvers/superstruct'
import React, { memo } from 'react'
import { useForm } from 'react-hook-form'
import type { SubmitHandler, FieldValues } from 'react-hook-form'
import { useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router'

import Button from '@/src/components/Button'
import Input from '@/src/components/Input/Input'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/NotFound/NotFound.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BrowserRouter } from 'react-router-dom'
import { BrowserRouter } from 'react-router'

import NotFound from '.'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Post/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ComponentProps } from 'react'
import React, { memo } from 'react'
import ReactMarkdown from 'react-markdown'
import { Link } from 'react-router-dom'
import { Link } from 'react-router'
import rehypeRaw from 'rehype-raw'
import breaks from 'remark-breaks'
import gfm from 'remark-gfm'
Expand Down
Loading

0 comments on commit d79f27d

Please sign in to comment.