Skip to content

hadiab/react-condition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>