Skip to content

Commit

Permalink
Upgraded to React 18 and latest React Router (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwngr authored Jul 7, 2024
1 parent 44fc8cc commit 56263ad
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 225 deletions.
157 changes: 46 additions & 111 deletions website/package-lock.json

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

13 changes: 6 additions & 7 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
"d3-geo": "^1.11.1",
"d3-scale-chromatic": "^1.3.3",
"date-fns": "^2.6.0",
"history": "^4.7.2",
"lodash": "^4.17.4",
"lodash": "^4.17.21",
"polished": "^3.4.2",
"prop-types": "^15.6.0",
"rc-slider": "^9.2.4",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-helmet": "^6.0.0",
"react-media": "^1.8.0",
"react-router-dom": "^5.1.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-helmet": "^6.1.0",
"react-media": "^1.10.0",
"react-router-dom": "^6.24.1",
"react-tweet-embed": "^1.1.0",
"styled-components": "^6.1.11",
"topojson-client": "^3.0.0",
Expand Down
45 changes: 45 additions & 0 deletions website/src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {lazy, Suspense} from 'react';
import {BrowserRouter, Route, Routes} from 'react-router-dom';
import {ThemeProvider} from 'styled-components';

import theme from '../resources/theme.json';

const AsyncFootballScheduleScreen = lazy(() =>
import('../screens/FootballScheduleScreen/index').then((module) => ({
default: module.FootballScheduleScreen,
}))
);

const AsyncExplorablesScreen = lazy(() =>
// @ts-expect-error TODO: Remove this after porting explorables to TypeScript.
import('../screens/ExplorablesScreen/index').then((module) => ({
default: module.ExplorablesScreen,
}))
);

export const App: React.FC = () => {
return (
<ThemeProvider theme={theme}>
<BrowserRouter>
<Routes>
<Route
path="/explorables/*"
element={
<Suspense fallback={null}>
<AsyncExplorablesScreen />
</Suspense>
}
/>
<Route
path="/:selectedYear?/:selectedGameIndex?/"
element={
<Suspense fallback={null}>
<AsyncFootballScheduleScreen />
</Suspense>
}
/>
</Routes>
</BrowserRouter>
</ThemeProvider>
);
};
4 changes: 1 addition & 3 deletions website/src/components/gameSummary/GameSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import clone from 'lodash/clone';
import React from 'react';

import {FullSchedule, TeamId} from '../../models';
Expand All @@ -12,8 +11,7 @@ export const GameSummary: React.FC<{
readonly selectedSeason: number;
readonly selectedGameIndex: number;
}> = ({selectedSeason, selectedGameIndex}) => {
const games = schedule[selectedSeason];
const game = clone(games[selectedGameIndex]);
const game = schedule[selectedSeason][selectedGameIndex];

const homeTeamId = game.isHomeGame ? TeamId.ND : game.opponentId;
const awayTeamId = game.isHomeGame ? game.opponentId : TeamId.ND;
Expand Down
Loading

0 comments on commit 56263ad

Please sign in to comment.