Skip to content

Commit

Permalink
Document serialization of data (vercel#3516)
Browse files Browse the repository at this point in the history
* Document serialization of data

* Add date
  • Loading branch information
timneutkens authored Dec 29, 2017
1 parent e80d9b4 commit a34f034
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`._
Expand Down

0 comments on commit a34f034

Please sign in to comment.