I'm trying to put an if else
statement inside JSX curly braces like:
<div>
{
if (condition) {
<h1>FOO</h1>
} else {
<h2>BAR</h1>
}
}
</div>
See here.
But I'm getting this error.
I'm trying to put an if else
statement inside JSX curly braces like:
<div>
{
if (condition) {
<h1>FOO</h1>
} else {
<h2>BAR</h1>
}
}
</div>
See here.
But I'm getting this error.
you can not use if keyword inside JSX. So to solve your issue
{
post.weather[0].main === "Haze" && <WiDayHaze size={100} color="black">
post.weather[0].main === "Sunny" && <WiSunrise size={100} color="black">
}