Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

Commit

Permalink
Reset current page upon search change
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb committed May 3, 2020
1 parent 0b22262 commit 8f4eb1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions webapp/src/ui/components/courses-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const CoursesList = ({data}) => {
const [page, setPage] = useState(0);
const [rowsPerPage, setRowsPerPage] = useState(50);

// Reset current page upon data change
useEffect(() => {
setPage(0);
}, [data]);

useEffect(() => {
setDisplayedData(data.slice(rowsPerPage * page, rowsPerPage * (page + 1)));
}, [rowsPerPage, page, data]);
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/ui/courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const Courses = () => {

<CoursesList data={filteredCourses}/>

<Backdrop open={courses.loading || courses.error} className={classes.backdrop}>
<Backdrop open={courses.loading === true || courses.error !== undefined} className={classes.backdrop}>
{courses.error ? (
<Paper>
<Box p={4} textAlign="center">
Expand Down

0 comments on commit 8f4eb1a

Please sign in to comment.