Web/React

React if문

__bo0o_ 2021. 5. 31. 01:11

보기 쉽게 정리하려 포스팅합니다.

 

1. React if

{ exampleIdx === 1 &&
    <div>1 출력</div>
}

{ exampleIdx === 2 &&
    <div>2 출력</div>
}
//Show if someItem
{someItem && displayThis}

//Show if else
{someItem ? displayThisIfTrue : displayThisIfFalse}

 

 

https://stackoverflow.com/questions/36771017/what-is-the-equivalent-to-ng-if-in-react-js