When you need state, lifecycle hooks or **initial data population** you can export a `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`.
When you need state, lifecycle hooks or **initial data population** you can export a `React.Component`.
```jsx
```jsx
importReactfrom'react'
importReactfrom'react'
...
@@ -124,6 +124,8 @@ export default class extends React.Component {
...
@@ -124,6 +124,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`.
### Routing
### Routing
Client-side transitions between routes are enabled via a `<Link>` component
Client-side transitions between routes are enabled via a `<Link>` component