Reputation: 19
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> }
}
Upvotes: 0
Views: 33
Reputation: 19
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
Upvotes: 0