Javascript 使用react呈现页面
我创建了这个函数,它实际上运行得很好:Javascript 使用react呈现页面,javascript,reactjs,firebase,google-cloud-firestore,Javascript,Reactjs,Firebase,Google Cloud Firestore,我创建了这个函数,它实际上运行得很好: const successPage = () => { firebase.auth().onAuthStateChanged((user) => { if(user) { console.log("calling success page : " + user.uid) firestore.collection("profiledata").do
const successPage = () => {
firebase.auth().onAuthStateChanged((user) => {
if(user) {
console.log("calling success page : " + user.uid)
firestore.collection("profiledata").doc(user.uid).update({
accountStatus: "active"
}).then (() => {
this.props.history.push(routes.LANDING)
})
}
})
}
问题是,当我尝试这样做时:
.then (() => {
this.props.history.push(routes.LANDING)
})
它返回以下错误:successPage(…):渲染未返回任何内容。这通常意味着缺少返回语句。或者,要不呈现任何内容,请返回null。
如何修复此问题?能否添加successPage.js?从外观上看,您只是忘记在jsx之前添加一个返回 例如:
function Welcome(props) {
*return* <h1>Hello, {props.name}</h1>;
}
功能欢迎(道具){
*return*Hello,{props.name};
}
你能包括处理着陆的组件吗
route@سعيد我在下面添加了Daniel所说的内容,它成功了,但我现在看到另一个错误。请看我下面的评论!是的,你是对的,我补充说,它起作用了。。。但现在我遇到了一个问题,它实际上不会仍然呈现该页面(routes.LANDING)。我试着做window.open(routes.LANDING)
,但它在chrome中打开了一个新窗口。如何让它转到另一个页面?您是否使用“react router dom”?