You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
582 B
JavaScript
22 lines
582 B
JavaScript
import { useState, useEffect } from "react";
|
|
import CourseCard from "./CourseCard";
|
|
|
|
export default function UserView({ coursesData }) {
|
|
const [courses, setCourses] = useState([]);
|
|
|
|
useEffect(() => {
|
|
const coursesArr = coursesData.map((course) => {
|
|
//only render the active products since the route used is /all from Course.js page
|
|
if (course.isActive === true) {
|
|
return <CourseCard courseProp={course} key={course._id} />;
|
|
} else {
|
|
return null;
|
|
}
|
|
});
|
|
|
|
setCourses(coursesArr);
|
|
}, [coursesData]);
|
|
|
|
return <>{courses}</>;
|
|
}
|