我的 React JS pastReviews 页面组件在运行时未呈现
My ReactJS pastReviews page component is no rendering when it is live
当我尝试加载我的 React 应用程序的过去评论页面时,我看到一个空白页面和我的 React 开发工具控制台中的以下错误
Uncaught Error: PastReviews(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null"
以下包含 PastReviews 页面组件的功能:
function PastReviews(){
let navigate = useNavigate();
const [user] = useAuthState(auth);
if(!user){
navigate("/");
}
const [review, setReview] = useState([]);
const reviewCollectionRef = collection(db, "review");
//this useEffect hooks contains an asynchronous function what fetches the dtata from firestore
useEffect(() => {
const getReview = async () =>{
const data = await getDocs(reviewCollectionRef);
setReview(data.docs.map((doc) => ({...doc.data(), id: doc.id})))
};
getReview();
},
[]);
//the following code displays the past reviews details from the firebase dataabase
{review.map((review) => {
return(
<><Header /><Card>
{""}
<label className='reviewQ'>General description of your experience with the module</label>
<label className='reviewQ'>What do you think of the lecturers teaching</label>
<label className='reviewQ'>How were the module contents taught?</label>
<label className='reviewQ'>How did you feel about the assessments</label>
<label className='reviewQ'>How could teaching be improved</label>
<label className='reviewQ'>How could assessments be improved</label>
<label className='reviewQ'>what did you think of the workload of this module</label>
<label className='reviewQ'>give some extra feedback</label>
<p>{review.q1}</p>
<p>{review.q2}</p>
<p>{review.q3}</p>
<p>{review.q4}</p>
<p>{review.q5}</p>
<p>{review.q6}</p>
<p>{review.q7}</p>
<p>{review.q8}</p>
</Card><Footer /></>
);
})}
}
如有任何帮助和建议,我们将不胜感激。
您在组件中缺少 return 语句。
还要检查要定义的评论。
return review && review.map((review) => {...})
当我尝试加载我的 React 应用程序的过去评论页面时,我看到一个空白页面和我的 React 开发工具控制台中的以下错误
Uncaught Error: PastReviews(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null"
以下包含 PastReviews 页面组件的功能:
function PastReviews(){
let navigate = useNavigate();
const [user] = useAuthState(auth);
if(!user){
navigate("/");
}
const [review, setReview] = useState([]);
const reviewCollectionRef = collection(db, "review");
//this useEffect hooks contains an asynchronous function what fetches the dtata from firestore
useEffect(() => {
const getReview = async () =>{
const data = await getDocs(reviewCollectionRef);
setReview(data.docs.map((doc) => ({...doc.data(), id: doc.id})))
};
getReview();
},
[]);
//the following code displays the past reviews details from the firebase dataabase
{review.map((review) => {
return(
<><Header /><Card>
{""}
<label className='reviewQ'>General description of your experience with the module</label>
<label className='reviewQ'>What do you think of the lecturers teaching</label>
<label className='reviewQ'>How were the module contents taught?</label>
<label className='reviewQ'>How did you feel about the assessments</label>
<label className='reviewQ'>How could teaching be improved</label>
<label className='reviewQ'>How could assessments be improved</label>
<label className='reviewQ'>what did you think of the workload of this module</label>
<label className='reviewQ'>give some extra feedback</label>
<p>{review.q1}</p>
<p>{review.q2}</p>
<p>{review.q3}</p>
<p>{review.q4}</p>
<p>{review.q5}</p>
<p>{review.q6}</p>
<p>{review.q7}</p>
<p>{review.q8}</p>
</Card><Footer /></>
);
})}
}
如有任何帮助和建议,我们将不胜感激。
您在组件中缺少 return 语句。 还要检查要定义的评论。
return review && review.map((review) => {...})