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:
parent
e80d9b4696
commit
a34f034021
|
@ -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`._
|
||||
|
|
Loading…
Reference in a new issue