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
*`prefetch: (pathname: string) => void` - Impertively prefetch _and cache_ data for a path. Under the hood this will map through your route tree, call the matching route's `getInitialProps`, store it, and then provide it to your page component. If the user ultimately navigates to that path, the data and component will be ready ahead of time. In the future, there may be more options to control cache behavior in the form of a function or time in milliseconds to keep that data around.
194
195
*`refetch: (nextCtx?: any) => void` - Imperatively call `getInitialProps` again
195
196
196
197
## Routing
@@ -201,7 +202,7 @@ routing. You can use any and all parts of RR4.
201
202
### Parameterized Routing
202
203
203
204
```js
204
-
// src/_route.js
205
+
//./src/_route.js
205
206
importHomefrom'./Home';
206
207
importAboutfrom'./About';
207
208
importDetailfrom'./Detail';
@@ -228,7 +229,7 @@ export default routes;
228
229
```
229
230
230
231
```js
231
-
// src/Detail.js
232
+
//./src/Detail.js
232
233
importReactfrom'react';
233
234
importNavLinkfrom'react-router-dom/NavLink';
234
235
@@ -277,7 +278,7 @@ the same exact way.
277
278
After,js lets you easily define lazy-loaded or code-split routes in your `_routes.js` file. To do this, you'll need to modify the relevant route's `component` definition like so:
@@ -307,10 +308,10 @@ While After.js comes with the battery pack included, you can customize and confi
307
308
308
309
### Custom `<Document>`
309
310
310
-
After.js works similarly to Next.js with respect to overriding HTML document structure. This comes in handy if you are using a CSS-in-JS library or just want to collect data out of react context before or after render. To do this, create a file in `./src/_document.js` like so:
311
+
After.js works similarly to Next.js with respect to overriding HTML document structure. This comes in handy if you are using a CSS-in-JS library or just want to collect data out of react context before or after render. To do this, create a file in `././src/_document.js` like so:
311
312
312
313
```js
313
-
// ./src/_document.js
314
+
// ././src/_document.js
314
315
importReactfrom'react';
315
316
316
317
classDocumentextendsReact.Component {
@@ -365,7 +366,7 @@ export default Document;
365
366
If you were using something like `styled-components`, and you need to wrap you entire app with some sort of additional provider or function, you can do this with `renderPage()`.
@@ -476,7 +477,7 @@ after comes with [Create React App's ESLint configuration](https://github.com/fa
476
477
* `process.env.HOST`: default is `0.0.0.0`
477
478
* `process.env.NODE_ENV`: `'development'` or `'production'`
478
479
* `process.env.BUILD_TARGET`: either `'client'` or `'server'`
479
-
* `process.env.PUBLIC_PATH`: Only in used in `after build`. You can alter the `webpack.config.output.publicPath` of the client assets (bundle, css, and images). This is useful if you plan to serve your assets from a CDN. Make sure to _include_ a trailing slash (e.g. `PUBLIC_PATH=https://cdn.example.com/`). If you are using React and altering the public path, make sure to also [include the `crossorigin` attribute](https://reactjs.org/docs/installation.html#using-a-cdn) on your `<script>` tag in `src/server.js`.
480
+
* `process.env.PUBLIC_PATH`: Only in used in `after build`. You can alter the `webpack.config.output.publicPath` of the client assets (bundle, css, and images). This is useful if you plan to serve your assets from a CDN. Make sure to _include_ a trailing slash (e.g. `PUBLIC_PATH=https://cdn.example.com/`). If you are using React and altering the public path, make sure to also [include the `crossorigin` attribute](https://reactjs.org/docs/installation.html#using-a-cdn) on your `<script>` tag in `./src/server.js`.
480
481
481
482
You can create your own custom build-time environment variables. They must start
482
483
with`AFTER_`. Any other variables except the ones listed above will be ignored to avoid accidentally exposing a private key on the machine that could have the same name. Changing any environment variables will require you to restart the development server if it is running.
*`prefetch: (pathname: string) => void` - Impertively prefetch _and cache_ data for a path. Under the hood this will map through your route tree, call the matching route's `getInitialProps`, store it, and then provide it to your page component. If the user ultimately navigates to that path, the data and component will be ready ahead of time. In the future, there may be more options to control cache behavior in the form of a function or time in milliseconds to keep that data around.
194
195
*`refetch: (nextCtx?: any) => void` - Imperatively call `getInitialProps` again
195
196
196
197
## Routing
@@ -201,7 +202,7 @@ routing. You can use any and all parts of RR4.
201
202
### Parameterized Routing
202
203
203
204
```js
204
-
// src/_route.js
205
+
//./src/_route.js
205
206
importHomefrom'./Home';
206
207
importAboutfrom'./About';
207
208
importDetailfrom'./Detail';
@@ -228,7 +229,7 @@ export default routes;
228
229
```
229
230
230
231
```js
231
-
// src/Detail.js
232
+
//./src/Detail.js
232
233
importReactfrom'react';
233
234
importNavLinkfrom'react-router-dom/NavLink';
234
235
@@ -277,7 +278,7 @@ the same exact way.
277
278
After,js lets you easily define lazy-loaded or code-split routes in your `_routes.js` file. To do this, you'll need to modify the relevant route's `component` definition like so:
@@ -307,10 +308,10 @@ While After.js comes with the battery pack included, you can customize and confi
307
308
308
309
### Custom `<Document>`
309
310
310
-
After.js works similarly to Next.js with respect to overriding HTML document structure. This comes in handy if you are using a CSS-in-JS library or just want to collect data out of react context before or after render. To do this, create a file in `./src/_document.js` like so:
311
+
After.js works similarly to Next.js with respect to overriding HTML document structure. This comes in handy if you are using a CSS-in-JS library or just want to collect data out of react context before or after render. To do this, create a file in `././src/_document.js` like so:
311
312
312
313
```js
313
-
// ./src/_document.js
314
+
// ././src/_document.js
314
315
importReactfrom'react';
315
316
316
317
classDocumentextendsReact.Component {
@@ -365,7 +366,7 @@ export default Document;
365
366
If you were using something like `styled-components`, and you need to wrap you entire app with some sort of additional provider or function, you can do this with `renderPage()`.
@@ -476,7 +477,7 @@ after comes with [Create React App's ESLint configuration](https://github.com/fa
476
477
* `process.env.HOST`: default is `0.0.0.0`
477
478
* `process.env.NODE_ENV`: `'development'` or `'production'`
478
479
* `process.env.BUILD_TARGET`: either `'client'` or `'server'`
479
-
* `process.env.PUBLIC_PATH`: Only in used in `after build`. You can alter the `webpack.config.output.publicPath` of the client assets (bundle, css, and images). This is useful if you plan to serve your assets from a CDN. Make sure to _include_ a trailing slash (e.g. `PUBLIC_PATH=https://cdn.example.com/`). If you are using React and altering the public path, make sure to also [include the `crossorigin` attribute](https://reactjs.org/docs/installation.html#using-a-cdn) on your `<script>` tag in `src/server.js`.
480
+
* `process.env.PUBLIC_PATH`: Only in used in `after build`. You can alter the `webpack.config.output.publicPath` of the client assets (bundle, css, and images). This is useful if you plan to serve your assets from a CDN. Make sure to _include_ a trailing slash (e.g. `PUBLIC_PATH=https://cdn.example.com/`). If you are using React and altering the public path, make sure to also [include the `crossorigin` attribute](https://reactjs.org/docs/installation.html#using-a-cdn) on your `<script>` tag in `./src/server.js`.
480
481
481
482
You can create your own custom build-time environment variables. They must start
482
483
with`AFTER_`. Any other variables except the ones listed above will be ignored to avoid accidentally exposing a private key on the machine that could have the same name. Changing any environment variables will require you to restart the development server if it is running.
0 commit comments