Skip to content

Commit

Permalink
class schedule bug fix
Browse files Browse the repository at this point in the history
Fixed a typo, removed an unnecessary method, and correctly changed state when new props were received
  • Loading branch information
g9singh committed Jan 18, 2019
1 parent 2c0b314 commit bfa7f66
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions app/views/schedule/ScheduleCardContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const getUpcomingClasses = (scheduleData) => {

if (defaultSelectedClass == null) {
defaultSelectedClass = 0
otherResults.lenth = MAX_RESULTS
otherResults.length = MAX_RESULTS
otherResults.push(...classesData.OTHER)
return otherResults
} else {
Expand All @@ -92,24 +92,20 @@ const getUpcomingClasses = (scheduleData) => {
class ScheduleCardContainer extends React.Component {
constructor(props) {
super(props)

this.state = {
upcoming4Courses: getUpcomingClasses(props.scheduleData),
activeCourse: null
activeCourse: defaultSelectedClass
}
this.onClickCourse = this.onClickCourse.bind(this)
}

componentWillMount() {
this.setState({ activeCourse: defaultSelectedClass })
}

/** TODO: Review ScheduleCardContainer::componentWillReceiveProps **/
// /** TODO: Review ScheduleCardContainer::componentWillReceiveProps **/
componentWillReceiveProps(nextProps) {
if ((nextProps.scheduleData) || (this.props.scheduleData && !nextProps.scheduleData)) {
this.setState((state, props) => ({
...state,
upcoming4Courses: getUpcomingClasses(props.scheduleData)
upcoming4Courses: getUpcomingClasses(props.scheduleData),
activeCourse: defaultSelectedClass
}))
}
}
Expand Down

0 comments on commit bfa7f66

Please sign in to comment.