我是React和Next.js的新手,所以请多多包涵。但是我花了三个小时进行搜索,因此无法终生弄清自己在做什么错。
this.props.test 即使看起来应该输出“ test”,也不会输出任何东西。
就像getInitialProps从来没有调用过。
class Example extends React.Component {
static async getInitialProps() {
return {
test: 'test'
}
}
render() {
return (
<h1>Hi {this.props.test}</h1>
)
}
}
Run Code Online (Sandbox Code Playgroud)