You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-3Lines changed: 17 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,16 +56,21 @@ npm run dev
56
56
-**fonts**
57
57
-**styles**
58
58
-**types**
59
+
-**views**
59
60
60
61
## How it works
61
62
62
63
### Server-Side Rendering
63
64
64
65
`./src` contains `App.tsx`, which is the entry point of the React app. It imports components from `./src/shared` and global styles from `./assets/styles/`. `App.tsx` is in turn imported by server (`server.tsx`) and client (`index.tsx`) files in `./src/server/` and `./src/client/`, respectively.
65
66
66
-
The `app.get()` method in server code (`./src/server/server.tsx`) specifies a callback function that will render to string React component from `App.tsx` and past it in a HTML template (`./src/server/indexTemplate.ts`), whenever there is an HTTP GET request with a path (`/`) relative to the site root.
67
+
The `app.get()` method in server code (`./src/server/server.tsx`) specifies a callback function that will render to string React component from `App.tsx` and past it in a template (`./src/views/index.tsx`), whenever there is an HTTP GET request with a path (`/`) relative to the site root.
67
68
68
-
After the `load` event is fired, the client code `hydrate` obtained React root. The `hydrate` method is used to render React components on the client side. It is similar to `render`, but it will attach event listeners to the existing markup instead of replacing it.
69
+
The server code use modern React method `renderToPipeableStream` to render React components to a stream. It is similar to `renderToString`, but it returns a Node.js Readable stream instead of a string. This is useful for sending the rendered HTML to the client in chunks.
70
+
71
+
The client code `hydrate` obtained React root. The `hydrate` method is used to render React components on the client side. It is similar to `render`, but it will attach event listeners to the existing markup instead of replacing it.
72
+
73
+
In the `App.tsx` component, `React.Suspense` component and `React.lazy` method can be used to load components asynchronously. The `React.Suspense` component is used to display a fallback component while waiting for the asynchronous component to load. The `React.lazy` function is used to load components asynchronously.
69
74
70
75
### Hot Module Replacement
71
76
@@ -93,12 +98,17 @@ It is possible to write snapshot tests (using `jest` and `react-test-renderer`)
93
98
94
99
The template contains a simple tests for the `Header` component. The test is located in the `./src/__tests__/Header.test.tsx` file.
95
100
101
+
### Dotenv
102
+
103
+
The `dotenv` package is used to load environment variables from a `.env` file into `process.env`. The `.env` files is located in the root folder of the project.
104
+
96
105
## What is used in the template?
97
106
98
107
### Server-Side Rendering
99
108
100
109
- Express server
101
110
- Nodemon
111
+
- Dotenv
102
112
103
113
### Hot Module Replacement
104
114
@@ -107,19 +117,22 @@ The template contains a simple tests for the `Header` component. The test is loc
107
117
- React Fast Refresh
108
118
- Webpack modules and plugins (webpack-dev-middleware, webpack-hot-middleware)
0 commit comments