我有一个小问题,React 和 Next.js 用户可能会帮助我。
我正在学习 React(使用 Next.js),但getStaticProps
. 疯狂的是 1 小时前它工作正常,但我不明白在此期间有什么可能会破坏它。
代码:
export async function getStaticProps() {
const response = await firebase.firestore().collection('votes').get();
const votes = response.docs.map((doc) => {
return doc.data();
});
console.log(votes);
return {
props: {
votes,
},
}
}
console.log 显示我有有效的可序列化数据:
[ { vote: 'true' }, { vote: 'false' } ]
我有这个错误:
Server Error
Error: invariant: getStaticProps did not return valid props. Please report this.
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
Object.renderToHTML
file:///Users/matthias/Projects/iremote/node_modules/next/dist/server/render.js (432:23)
async doRender
file:///Users/matthias/Projects/iremote/node_modules/next/dist/server/next-server.js (1127:38)
async
file:///Users/matthias/Projects/iremote/node_modules/next/dist/server/next-server.js (1221:28)
async
file:///Users/matthias/Projects/iremote/node_modules/next/dist/server/response-cache.js (60:36)
我的代码似乎很正确,但疯狂的是我在互联网上找不到任何提及此特定错误的信息。