0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

目次

はじめに

今回は、ReactのRouter設定のフローを紹介する

インストール

react-router-domをインストールする

npm install react-router-dom

プロジェクト内での作成

  • srcフォルダ配下にrouterフォルダを作成
  • Router.tsxを作成
import { memo, type FC } from "react";
import { Route, Routes } from "react-router-dom";

export const Router: FC = memo(() => {
    return (
        <Routes>
            <Route path="/" element={<??? />} />
        </Routes>
    )
})
  • App.tsxを以下のように変更する
import { BrowserRouter } from 'react-router-dom';
import { Router } from './router/Router';

export const App = () => {
  return (
    <BrowserRouter>
      <Router />
    </BrowserRouter>
    );
};
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?