I am using React hooks and following is the conditional rendering which I want to achieve where sortDirection is a state. I want to render one of the <i> tag based on sortDirection. How can I achieve this ?
if (sortDirection == "ascending") {
return <i onclick={() => setSortDirection('descending')} className="fa fa-arrow-down" />
} else if (sortDirection == "descending") {
return <i onClick={() => setSortDirection('random')} className="fa fa-arrow-up" />
} else {
return <i onClick={() => setSortDirection('ascending')} className="fa fa-arrow-h" />
}