convert ManageCoursePage from class to function with hooks

master
Tudor Stanciu 2020-04-11 23:35:57 +03:00
parent 3a6fcd1637
commit 2fe0b6c647
1 changed files with 9 additions and 13 deletions

View File

@ -1,14 +1,12 @@
import React from "react";
import React, { useEffect } from "react";
import { connect } from "react-redux";
import { loadCourses } from "../../redux/actions/courseActions";
import { loadAuthors } from "../../redux/actions/authorActions";
import PropTypes from "prop-types";
import { bindActionCreators } from "redux";
class ManageCoursePage extends React.Component {
componentDidMount() {
const { courses, authors, actions } = this.props;
function ManageCoursePage({ courses, authors, actions }) {
useEffect(() => {
if (courses.length === 0) {
actions.loadCourses().catch((error) => {
alert("Loading courses failed. " + error);
@ -20,15 +18,13 @@ class ManageCoursePage extends React.Component {
alert("Loading authors failed. " + error);
});
}
}
}, []);
render() {
return (
<>
<h2>Manage course</h2>
</>
);
}
}
ManageCoursePage.propTypes = {