Skip to content

Commit

Permalink
no log: Updated react router to v7 (#2823)
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson-oki authored Jan 14, 2025
1 parent c7195db commit 9fc7752
Show file tree
Hide file tree
Showing 24 changed files with 70 additions and 58 deletions.
2 changes: 1 addition & 1 deletion frontend/config/chunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { dependencies } from "../package.json";

const vendors = [
"react",
"react-router-dom",
"react-router",
"react-dom",
"@tanstack/react-query",
"axios",
Expand Down
73 changes: 43 additions & 30 deletions frontend/package-lock.json

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

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"braces": "^3.0.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.23.1",
"react-router": "^7.1.1",
"socket.io-client": "^4.7.5"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/App/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, {
useMemo,
useState,
} from "react";
import { matchPath, NavLink, RouteObject, useLocation } from "react-router-dom";
import { matchPath, NavLink, RouteObject, useLocation } from "react-router";
import {
Anchor,
AppShell,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/App/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent, useEffect, useState } from "react";
import { Outlet, useNavigate } from "react-router-dom";
import { Outlet, useNavigate } from "react-router";
import { AppShell } from "@mantine/core";
import { useWindowEvent } from "@mantine/hooks";
import { showNotification } from "@mantine/notifications";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Router/Redirector.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { useNavigate } from "react-router";
import { LoadingOverlay } from "@mantine/core";
import { useSystemSettings } from "@/apis/hooks";

Expand Down
7 changes: 5 additions & 2 deletions frontend/src/Router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
useContext,
useMemo,
} from "react";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import { createBrowserRouter, RouterProvider } from "react-router";
import {
faClock,
faCogs,
Expand Down Expand Up @@ -324,7 +324,10 @@ export const Router: FunctionComponent = () => {

// TODO: Move this outside the function component scope
const router = useMemo(
() => createBrowserRouter(routes, { basename: Environment.baseUrl }),
() =>
createBrowserRouter(routes, {
basename: Environment.baseUrl,
}),
[routes],
);

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Router/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RouteObject } from "react-router-dom";
import { RouteObject } from "react-router";
import { IconDefinition } from "@fortawesome/free-solid-svg-icons";

declare namespace Route {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent, useMemo, useState } from "react";
import { useNavigate } from "react-router-dom";
import { useNavigate } from "react-router";
import {
ComboboxItem,
em,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Blacklist/Movies/table.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Link } from "react-router";
import { Anchor, Text } from "@mantine/core";
import { faTrash } from "@fortawesome/free-solid-svg-icons";
import { ColumnDef } from "@tanstack/react-table";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Blacklist/Series/table.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Link } from "react-router";
import { Anchor, Text } from "@mantine/core";
import { faTrash } from "@fortawesome/free-solid-svg-icons";
import { ColumnDef } from "@tanstack/react-table";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Episodes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
useRef,
useState,
} from "react";
import { Navigate, useParams } from "react-router-dom";
import { Navigate, useParams } from "react-router";
import { Container, Group, Stack } from "@mantine/core";
import { Dropzone } from "@mantine/dropzone";
import { useDocumentTitle } from "@mantine/hooks";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/History/Movies/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable camelcase */
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Link } from "react-router";
import { Anchor, Badge, Text } from "@mantine/core";
import {
faFileExcel,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/History/Series/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable camelcase */
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Link } from "react-router";
import { Anchor, Badge, Text } from "@mantine/core";
import {
faFileExcel,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Movies/Details/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent, useCallback, useRef } from "react";
import { Navigate, useParams } from "react-router-dom";
import { Navigate, useParams } from "react-router";
import { Container, Group, Menu, Stack } from "@mantine/core";
import { Dropzone } from "@mantine/dropzone";
import { useDocumentTitle } from "@mantine/hooks";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Movies/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Link } from "react-router";
import { Anchor, Badge, Container } from "@mantine/core";
import { useDocumentTitle } from "@mantine/hooks";
import { faBookmark as farBookmark } from "@fortawesome/free-regular-svg-icons";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Series/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Link } from "react-router";
import { Anchor, Container, Group, Progress } from "@mantine/core";
import { useDocumentTitle } from "@mantine/hooks";
import { faBookmark as farBookmark } from "@fortawesome/free-regular-svg-icons";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Wanted/Movies/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Link } from "react-router";
import { Anchor, Badge, Group } from "@mantine/core";
import { faSearch } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Wanted/Series/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Link } from "react-router";
import { Anchor, Badge, Group } from "@mantine/core";
import { faSearch } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/views/ItemView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useNavigate } from "react-router-dom";
import { useNavigate } from "react-router";
import { faList } from "@fortawesome/free-solid-svg-icons";
import { ColumnDef } from "@tanstack/react-table";
import { UsePaginationQueryResult } from "@/apis/queries/hooks";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/views/MassEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useMemo, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
import { useNavigate } from "react-router";
import { Box, Container, useCombobox } from "@mantine/core";
import { faCheck, faUndo } from "@fortawesome/free-solid-svg-icons";
import { UseMutationResult } from "@tanstack/react-query";
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/tests/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import {
ReactElement,
StrictMode,
} from "react";
import {
createBrowserRouter,
RouteObject,
RouterProvider,
} from "react-router-dom";
import { createBrowserRouter, RouteObject, RouterProvider } from "react-router";
import { render, RenderOptions } from "@testing-library/react";
import { AllProviders } from "@/providers";

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utilities/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useRef,
useState,
} from "react";
import { useNavigate } from "react-router-dom";
import { useNavigate } from "react-router";
import { SliderProps } from "@mantine/core";
import { SelectorOption, SelectorProps } from "@/components";

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utilities/routers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// A workaround of built-in hooks in React-Router v6
// https://gist.github.com/rmorse/426ffcc579922a82749934826fa9f743

import { unstable_usePrompt as useUnstablePrompt } from "react-router-dom";
import { unstable_usePrompt as useUnstablePrompt } from "react-router";

// TODO: Replace with Mantine's confirmation modal
export function usePrompt(when: boolean, message: string) {
Expand Down

0 comments on commit 9fc7752

Please sign in to comment.