Improve scroll handling and cache fetch results

This commit is contained in:
2020-02-17 00:19:44 +00:00
parent 2aff4e97b6
commit 8555fbfa0f
6 changed files with 76 additions and 19 deletions
+4 -1
View File
@@ -8,14 +8,17 @@ import { NotFound, PleaseLogin } from './Misc.js';
import { InstructorCourseList, InstructorCourseDetail } from './InstructorCourses.js';
import { InstructorClassList } from './InstructorClasses.js';
let courseCache = false;
export function Courses(props) {
const [courses, setCourses] = useState(false);
const [courses, setCourses] = useState(courseCache);
const { token, user } = props;
useEffect(() => {
requester('/courses/', 'GET', token)
.then(res => {
setCourses(res.results);
courseCache = res.results;
})
.catch(err => {
console.log(err);