Skip to content

Commit

Permalink
FEI-5465.2: Add basic routing using React Router v5 (#2)
Browse files Browse the repository at this point in the history
## Summary:
Before we can start adding examples of different React perf issues, we need a basic site layout to house the examples.  This PR routing using React Router v5.  I know it's out of date, but I didn't want to learn something new just for this workshop repo so I went with the familiar.  I've also removed the .css and asset files.

Issue: FEI-5465

## Test plan:
- yarn dev
- visit http://localhost:5173
- click around and check that the navigation works

<img width="880" alt="Screen Shot 2024-02-21 at 5 31 58 PM" src="https://github.com/Khan/frontend-infra-workshops/assets/1044413/52ba161c-fb58-4de0-ab5c-f8e6fda09c8a">
<img width="880" alt="Screen Shot 2024-02-21 at 5 32 01 PM" src="https://github.com/Khan/frontend-infra-workshops/assets/1044413/4abdd909-e06d-45d2-a8a4-4bc390c02e06">

Author: kevinbarabash

Reviewers: jeresig, somewhatabstract

Required Reviewers:

Approved By: jeresig

Checks: ✅ Lint (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x)

Pull Request URL: #2
  • Loading branch information
kevinbarabash authored Feb 22, 2024
1 parent 8ded53c commit 6bada65
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 158 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-router": "5",
"react-router-dom": "5"
},
"devDependencies": {
"@khanacademy/eslint-config": "^4.0.0",
"@khanacademy/eslint-plugin": "^3.0.0",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"@types/react-router": "5",
"@types/react-router-dom": "5",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@vitejs/plugin-react-swc": "^3.5.0",
Expand Down
42 changes: 0 additions & 42 deletions src/App.css

This file was deleted.

39 changes: 0 additions & 39 deletions src/App.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/react.svg

This file was deleted.

14 changes: 14 additions & 0 deletions src/homepage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Link} from "react-router-dom";

export default function Homepage() {
return (
<>
<h1>Frontend Infra Workshops</h1>
<ul>
<li>
<Link to="react-render-perf">React Render Perf</Link>
</li>
</ul>
</>
);
}
68 changes: 0 additions & 68 deletions src/index.css

This file was deleted.

6 changes: 3 additions & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.tsx";
import "./index.css";

import Routes from "./routes";

ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
<Routes />
</React.StrictMode>,
);
21 changes: 21 additions & 0 deletions src/react-render-perf/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Link} from "react-router-dom";

export default function ReactRenderPerf() {
return (
<>
<Link to="/">Home</Link>
<h1>React Render Perf</h1>
<ul>
<li>
<Link to="example-1">Example 1</Link>
</li>
<li>
<Link to="example-2">Example 2</Link>
</li>
<li>
<Link to="example-3">Example 3</Link>
</li>
</ul>
</>
);
}
17 changes: 17 additions & 0 deletions src/routes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {BrowserRouter, Route} from "react-router-dom";

import ReactRenderPerf from "./react-render-perf";
import Homepage from "./homepage";

export default function Routes() {
return (
<BrowserRouter>
<Route path="/" exact={true}>
<Homepage />
</Route>
<Route path="/react-render-perf" exact={true}>
<ReactRenderPerf />
</Route>
</BrowserRouter>
);
}
Loading

0 comments on commit 6bada65

Please sign in to comment.