@@ -20,6 +20,7 @@ import ChallengeCheckpoints from 'components/challenge-detail/Checkpoints';
20
20
import React from 'react' ;
21
21
import PT from 'prop-types' ;
22
22
import { connect } from 'react-redux' ;
23
+ import Error404 from 'components/Error404' ;
23
24
import challengeActions from 'actions/challenge' ;
24
25
import termsActions from 'actions/terms' ;
25
26
import config from 'utils/config' ;
@@ -56,6 +57,10 @@ class ChallengeDetailPageContainer extends React.Component {
56
57
const { challenge, loadChallengeDetails, loadTerms,
57
58
openTermsModal, authTokens, challengeId } = this . props ;
58
59
60
+ if ( isNaN ( challengeId ) ) {
61
+ return ;
62
+ }
63
+
59
64
if ( challenge . id !== challengeId ) {
60
65
loadChallengeDetails ( authTokens , challengeId ) ;
61
66
}
@@ -68,6 +73,10 @@ class ChallengeDetailPageContainer extends React.Component {
68
73
}
69
74
70
75
componentWillReceiveProps ( nextProps ) {
76
+ if ( isNaN ( nextProps . challengeId ) ) {
77
+ return ;
78
+ }
79
+
71
80
if ( this . props . tokenV3 !== nextProps . tokenV3 ) {
72
81
this . props . reloadChallengeDetails ( nextProps . authTokens , this . props . challengeId ) ;
73
82
}
@@ -118,6 +127,10 @@ class ChallengeDetailPageContainer extends React.Component {
118
127
}
119
128
120
129
render ( ) {
130
+ if ( isNaN ( this . props . challengeId ) ) {
131
+ return < Error404 /> ;
132
+ }
133
+
121
134
const isEmpty = _ . isEmpty ( this . props . challenge ) ;
122
135
123
136
const hasRegistered = isRegistered ( this . props . challenge . userDetails ,
@@ -286,6 +299,9 @@ ChallengeDetailPageContainer.propTypes = {
286
299
287
300
function extractChallengeDetail ( v3 , v2 , challengeId ) {
288
301
let challenge = { } ;
302
+ if ( isNaN ( challengeId ) ) {
303
+ return challenge ;
304
+ }
289
305
if ( ! _ . isEmpty ( v3 ) ) {
290
306
challenge = _ . clone ( v3 ) ;
291
307
if ( ! _ . isEmpty ( v2 ) ) {
0 commit comments