Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 654 Bytes

README.md

File metadata and controls

45 lines (33 loc) · 654 Bytes

React Condition

React conditional rendering more friendly way

Install

npm install reactjs-condition
yarn add reactjs-condition

How it works?

import { If } from 'reactjs-condition'

<If condition={true}>
  <div>TRUE</div>
</If>
import { If, Else } from 'reactjs-condition'

<If condition={false}>
  <div>TRUE</div>
<Else />
  <div>FALSE</div>
</If>
import { If, ElseIf, Else } from 'reactjs-condition'

const fruit = 'Apple'

<If condition={fruit === 'Apple'}>
  <div>Apple</div>
<ElseIf condition={fruit === 'Orange'} />
  <div>Orange</div>
<Else />
  <div>Banana</div>
</If>