Skip to content

Commit 219b224

Browse files
committed
static page generation
1 parent 1d80fbc commit 219b224

File tree

5 files changed

+11960
-14
lines changed

5 files changed

+11960
-14
lines changed

reactjsfoundations.com/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"start": "react-scripts start",
3131
"prebuild": "npm run sitemap",
3232
"build": "react-scripts build",
33+
"postbuild": "react-snap",
3334
"test": "react-scripts test",
3435
"eject": "react-scripts eject",
3536
"sitemap": "babel-node ./sitemap-gen.js"
@@ -66,6 +67,7 @@
6667
"fs": "^0.0.1-security",
6768
"path": "^0.12.7",
6869
"prettier": "^2.6.2",
69-
"react-app-rewired": "^2.2.1"
70+
"react-app-rewired": "^2.2.1",
71+
"react-snap": "^1.23.0"
7072
}
7173
}

reactjsfoundations.com/src/chapter12/NestedRoutes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ function Reports() {
1515

1616
return (
1717
<>
18-
<div>
19-
<h2>Reports</h2>
18+
{/*<div>
19+
<h2>Reports</h2>
2020
<ul>
2121
<li>
2222
<Link to={`${url}/profitloss`}>Profit and Loss</Link>
@@ -37,7 +37,7 @@ function Reports() {
3737
<Report />
3838
</Route>
3939
</Switch>
40-
</div>
40+
</div> */}
4141
<SyntaxHighlighter language="javascript" style={github}>
4242
{`import {
4343
BrowserRouter as Router,

reactjsfoundations.com/src/index.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom/client';
2+
import { createRoot, hydrateRoot } from 'react-dom/client';
33
import { BrowserRouter as Router } from 'react-router-dom';
44
import App from './App';
55
import ScrollToTop from './ScrollToTop';
66

7-
ReactDOM.createRoot(document.getElementById('root')).render(
8-
<Router>
9-
<ScrollToTop>
10-
<App />
11-
</ScrollToTop>
12-
</Router>
13-
);
7+
const container = document.getElementById('root');
8+
9+
if (container.hasChildNodes()) {
10+
hydrateRoot(
11+
container,
12+
<Router>
13+
<ScrollToTop>
14+
<App />
15+
</ScrollToTop>
16+
</Router>
17+
);
18+
} else {
19+
createRoot(container).render(
20+
<Router>
21+
<ScrollToTop>
22+
<App />
23+
</ScrollToTop>
24+
</Router>
25+
);
26+
}

reactjsfoundations.com/src/routes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,7 +3269,7 @@ export default Route;
32693269

32703270
<Chapter12.ViewLocation />
32713271
</Route>
3272-
<Route path="/listing1216">
3272+
{/* <Route path="/listing1216">
32733273
<Helmet>
32743274
<title>
32753275
ReactJS Foundations: Dynamic Links and Routes in nested Routes
@@ -3279,7 +3279,7 @@ export default Route;
32793279
<PrevNext prev="/listing1215" next="/listing1301" />
32803280
32813281
<Chapter12.NestedRoutes />
3282-
</Route>
3282+
</Route> */}
32833283
<Route path="/listing1301">
32843284
<Helmet>
32853285
<title>ReactJS Foundations: An ErrorBoundary component</title>

0 commit comments

Comments
 (0)