An open API service indexing awesome lists of open source software.

https://github.com/davinci2015/react-ternary

Ternary operator in a declarative way
https://github.com/davinci2015/react-ternary

conditional-statements react ternary

Last synced: 4 months ago
JSON representation

Ternary operator in a declarative way

Awesome Lists containing this project

README

        

# react-ternary

Use ternary conditional operator in a declarative way.

## Installation

```bash
npm install react-ternary --save
```

## Usage

Instead of:
```js
import React, { Component } from 'react'

class App extends Component {
render() {
return(


{
this.props.language === 'JS' ?
Language is JS
:
Language is not JS

}

)
}
}
```

you can use ternary in a declarative way:
```js
import React, { Component } from 'react'
import Ternary from 'react-ternary'

class App extends Component {
render() {
return(

Language is JS
{/* first element will render if condition is true */}
Language is not JS
{/* second element will render if condition is false */ }

)
}
}
```