当试图在组件上定义getInitialProps方法时,我会收到一个The field getInitialProps does not belong to type ReasonReact.componentSpec我应该如何在React组件上添加这个自定义方法?ReasonReact.statelessComponent("Index");
...component,
getInitialP
我有一个布局组件,需要onAppBarInputChange道具。onAppBarInputChange支柱需要一个函数,该函数从布局组件获取输入值,并根据该输入值过滤待办事项。如何将道具从待办事项页面传递到布局组件?import {useState} from 'react' some footer here
<
但是,当我尝试使用isomorphic-unfetch将数据getInitialProps到页面中时,请求返回数据,但不能将其转换为属性。对于_document.js,我使用的是来自next.js站点的代码,并且还尝试了一个与略有不同的版本,我在next.js文档站点上也看到了这个版本。我的测试页面如下所示(也来自next.js ):import fetch from
基于官方NextJS文档中的这个NextJS,他们建议使用getServerSidedProps和getStaticProps而不是getInitialProps。有人知道如何在服务器上预加载数据吗?我不想使用useEffect of componentDidMount并在客户机上设置数据。我知道有一个库正在修复这个问题,但是它正在使用getInitialProps,我想看看是否可以这样做。
我试图将我的主题对象传递给Next.js项目中的styled-components,但它总是无法将其作为道具接收。那是我的_document.tsximport Document, {ThemeProvider nor passing a theme prop or a theme in defaultProps in component class &q