1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Document serialization of data (#3516)

* Document serialization of data

* Add date
This commit is contained in:
Tim Neutkens 2017-12-29 21:33:49 +01:00 committed by GitHub
parent e80d9b4696
commit a34f034021
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -249,6 +249,8 @@ export default class extends React.Component {
Notice that to load data when the page loads, we use `getInitialProps` which is an [`async`](https://zeit.co/blog/async-and-await) static method. It can asynchronously fetch anything that resolves to a JavaScript plain `Object`, which populates `props`.
Data returned from `getInitialProps` is serialized when server rendering, similar to a `JSON.stringify`. Make sure the returned object from `getInitialProps` is a plain `Object` and not using `Date`, `Map` or `Set`.
For the initial page load, `getInitialProps` will execute on the server only. `getInitialProps` will only be executed on the client when navigating to a different route via the `Link` component or using the routing APIs.
_Note: `getInitialProps` can **not** be used in children components. Only in `pages`._