Closed jyang1003 closed 2 years ago
Is it supposed to be literally undefined, or is it some kind of empty key/object? I.e. what's being passed in as props*
Instead of checking against undefined
, try formatting your statement like this if(!props.currentProfile)
to check for any falsey value.
currentProfile is set to null. It's a state being passed in from app.js to profile.js
Instead of checking against
undefined
, try formatting your statement like thisif(!props.currentProfile)
to check for any falsey value.
This doesn't work for some reason
does props.currentProfile show as null in the react dev tools too?
No, it gives the following messages:
DocumentNotFoundError
Message: the provided ID doesn't match any documents
status: 404
Wait what? I'mma come into your room
please close with your solution :)
Changed if statement to if(!props.currentProfile.age)
to make it a falsey value.
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
MERN
What's the problem you're trying to solve?
If conditional isn't met for some reason
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
No error message, just doesn't meet that conditional even though the user does not have a profile
What is your best guess as to the source of the problem?
It's giving me a message instead of setting the state to undefined for some reason
What things have you already tried to solve the problem?
manually setting currentProfile to undefined to start googling message