2

This is my code basically:

const [jwtToken, setJwtToken] = useState("")
return(
    {(jwtToken === "") ? <div>Yes</div> : <div>No</div>}
)

Why do I get this error?:

enter image description here

2 Answers 2

1

I remember it worked like this for me (added some parentheses and empty html tag):

return(
  <>{(jwtToken === "") ? (<div>Yes</div>) : (<div>No</div>)}</>
)
Sign up to request clarification or add additional context in comments.

Comments

0
  const [jwtToken, setJwtToken] = useState("")
  return (
    (jwtToken === "") ? <div>Yes</div> : <div>No</div>
  )

In this case you don't need to use {}

You can also use React.Fragment

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.