问题
I know I ask this on the eve of React Hooks being released but I was wondering - is it possible to create Page components as a Class component instead of a Function component?
When I convert the default Gatsby starter src/pages/index.js
page to a Class component as such
class IndexPage extends React.Component {
render() {
return (
<div>I am a class component</div>
)
}
}
export default IndexPage
I get this error (AppContainer)TypeError: Cannot set property 'props' of undefined
I couldn't find any documentation on this 😕
回答1:
You have a typo in your code, export default IndexPage instead of return.
来源:https://stackoverflow.com/questions/54539658/gatsby-page-components-as-class-components