Double check props before exploring movies / shows
This commit is contained in:
parent
a3a9d65f9b
commit
ed46bdcf5e
@ -11,9 +11,11 @@ export default class ExplorerOptions extends React.Component {
|
||||
// Check if the options are present
|
||||
if (Object.keys(this.props.options).length === 0) {
|
||||
// Fetch options
|
||||
this.props.fetchOptions();
|
||||
props.fetchOptions();
|
||||
// Explore
|
||||
this.props.explore(this.props.params.source, this.props.params.category);
|
||||
if (this.propsValid(props)) {
|
||||
props.explore(props.params.source, props.params.category);
|
||||
}
|
||||
} else {
|
||||
source = this.props.params.source;
|
||||
category = this.props.params.category;
|
||||
@ -42,12 +44,19 @@ export default class ExplorerOptions extends React.Component {
|
||||
this.setState({ selectedCategory: event.target.value });
|
||||
this.props.router.push(`/${this.props.type}/explore/${this.state.selectedSource}/${event.target.value}`);
|
||||
}
|
||||
propsValid(props) {
|
||||
if (!props.params
|
||||
|| !props.params.source
|
||||
|| !props.params.category
|
||||
|| (props.params.source === "")
|
||||
|| (props.params.category === "")) {
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
}
|
||||
componentWillUpdate(nextProps, nextState) {
|
||||
// Check props
|
||||
if (!nextProps.params.source
|
||||
|| !nextProps.params.category
|
||||
|| (nextProps.params.source === "")
|
||||
|| (nextProps.params.category === "")) {
|
||||
if (!this.propsValid(nextProps)) {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user