WDI-SEA / project-4-issues

Open an issue to receive help on project 4 issues
0 stars 0 forks source link

If statement not working #26

Closed jyang1003 closed 2 years ago

jyang1003 commented 2 years ago

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 (props.currentProfile === undefined) {

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

tkolsrud commented 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*

timmshinbone commented 2 years ago

Instead of checking against undefined, try formatting your statement like this if(!props.currentProfile) to check for any falsey value.

jyang1003 commented 2 years ago

currentProfile is set to null. It's a state being passed in from app.js to profile.js

jyang1003 commented 2 years ago

Instead of checking against undefined, try formatting your statement like this if(!props.currentProfile) to check for any falsey value.

This doesn't work for some reason

TaylorDarneille commented 2 years ago

does props.currentProfile show as null in the react dev tools too?

jyang1003 commented 2 years ago

No, it gives the following messages: DocumentNotFoundError Message: the provided ID doesn't match any documents status: 404

TaylorDarneille commented 2 years ago

Wait what? I'mma come into your room

TaylorDarneille commented 2 years ago

please close with your solution :)

jyang1003 commented 2 years ago

Changed if statement to if(!props.currentProfile.age) to make it a falsey value.