0

Expected to return a value at the end of arrow function , this is a common problem one can face easily while using react JSX in strict mode

contentType = id => {

console.log('')

if (id === 'COURSE') {
  return <div>{id}</div>
}
if (id === 'PROJECT') {
  return <div>{id}</div>
}   

}

1 Answer 1

0

right ans is

contentType = id => { console.log('')

if (id === 'COURSE') {
  return <div>{id}</div>
}
if (id === 'PROJECT') {
  return <div>{id}</div>
}
return ''  

}

dont leave without no return at the end , at react strict mode this happen , last and default condition always goes at the end with no extra block

Sign up to request clarification or add additional context in comments.

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.