从无法访问的项目Fork
体验新版 GitCode,发现更多精彩内容 >>
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> } }