Due to react's nature i have to use the ternary operator to output some code. I am getting a parse error because i have JS code as well as html in the output. How can i insert both the JS and html in this ternary statement?
JS
<div>
{
props.starring? "..some code"
:
(
const starrarr = JSON.parse("["+props.starring+"]") //this line is giving me an error
<div className="altactorimg">
<h6><img src="#" alt="pictures"/>{starrarr[0]}</h6>
<h6><img src="#" alt="pictures"/>{starrarr[1]}</h6>
<h6><img src="#" alt="pictures"/>{starrarr[2]}</h6>
</div>
)
}
</div>
I attempted many things like wrapping them inside brackets, and adding JSON.parse directly inside each element but still get errors.
Note: the above code is react jsx