Skip to content

Commit c5a6ba1

Browse files
kunalpanchalgaearon
authored andcommitted
Fix for SSR2 fixture not working locally (#24237)
* SS2 fixture not working locally fix * Fix prettier issue * prettier excess line fix * Update render.js * Update README.md Co-authored-by: dan <[email protected]>
1 parent 36fb361 commit c5a6ba1

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

fixtures/ssr2/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SSR Fixtures
2+
3+
A set of test cases for quickly identifying issues with server-side rendering.
4+
5+
## Setup
6+
7+
To reference a local build of React, first run `npm run build` at the root
8+
of the React project. Then:
9+
10+
```
11+
cd fixtures/ssr2
12+
yarn
13+
yarn start
14+
```
15+
16+
The `start` command runs a webpack dev server and a server-side rendering server in development mode with hot reloading.
17+
18+
**Note: whenever you make changes to React and rebuild it, you need to re-run `yarn` in this folder:**
19+
20+
```
21+
yarn
22+
```
23+
24+
If you want to try the production mode instead run:
25+
26+
```
27+
yarn start:prod
28+
```
29+
30+
This will pre-build all static resources and then start a server-side rendering HTTP server that hosts the React app and service the static resources (without hot reloading).

fixtures/ssr2/scripts/build.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ webpack(
4040
console.error(err.details);
4141
}
4242
process.exit(1);
43-
return;
4443
}
4544
const info = stats.toJson();
4645
if (stats.hasErrors()) {

fixtures/ssr2/server/render.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ let assets = {
2020
};
2121

2222
module.exports = function render(url, res) {
23+
const data = createServerData();
2324
// This is how you would wire it up previously:
2425
//
2526
// res.send(
@@ -36,14 +37,17 @@ module.exports = function render(url, res) {
3637
console.error('Fatal', error);
3738
});
3839
let didError = false;
39-
const data = createServerData();
4040
const {pipe, abort} = renderToPipeableStream(
4141
<DataProvider data={data}>
4242
<App assets={assets} />
4343
</DataProvider>,
4444
{
4545
bootstrapScripts: [assets['main.js']],
46-
onCompleteShell() {
46+
onAllReady() {
47+
// Full completion.
48+
// You can use this for SSG or crawlers.
49+
},
50+
onShellReady() {
4751
// If something errored before we started streaming, we set the error code appropriately.
4852
res.statusCode = didError ? 500 : 200;
4953
res.setHeader('Content-type', 'text/html');

0 commit comments

Comments
 (0)