Skip to content

Instantly share code, notes, and snippets.

@takunagai
Created May 19, 2022 00:10
Show Gist options
  • Save takunagai/69e7ba6d4ee130b6abdaab3e68938faf to your computer and use it in GitHub Desktop.
Save takunagai/69e7ba6d4ee130b6abdaab3e68938faf to your computer and use it in GitHub Desktop.
[jsx conditional statement] #react #jsx
<>
<p className={isActive && 'active'}>item</p>
<p className={'background' + (isActive && 'active')}>item("false" if the condition is mismatched.)</p>
<p className={`background${isActive && 'active'}`}>item</p>
<p className={isActive ? 'active' : 'disable'}>item</p>
<p className={'background' + (isActive ? 'active' : 'disable')}>item</p>
<p className={`background${isActive ? 'active' : 'disable'}`}>item</p>
</>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment