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
- Host: GitHub
- URL: https://github.com/davinci2015/react-ternary
- Owner: davinci2015
- License: mit
- Created: 2018-03-04T13:20:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-05T11:57:18.000Z (over 7 years ago)
- Last Synced: 2025-01-10T09:04:16.171Z (6 months ago)
- Topics: conditional-statements, react, ternary
- Language: JavaScript
- Homepage:
- Size: 102 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 */ }
)
}
}
```