mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
19 lines
372 B
JavaScript
19 lines
372 B
JavaScript
|
import React from 'react'
|
||
|
|
||
|
export default class AsyncProps extends React.Component {
|
||
|
static async getInitialProps () {
|
||
|
return await AsyncProps.fetchData()
|
||
|
}
|
||
|
|
||
|
static fetchData () {
|
||
|
const p = new Promise(resolve => {
|
||
|
setTimeout(() => resolve({ name: 'Diego Milito' }), 10)
|
||
|
})
|
||
|
return p
|
||
|
}
|
||
|
|
||
|
render () {
|
||
|
return <p>{this.props.name}</p>
|
||
|
}
|
||
|
}
|