0.1.3 • Published 6 years ago

react-ternary v0.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

react-ternary

Use ternary conditional operator in a declarative way.

Installation

npm install react-ternary --save

Usage

Instead of:

import React, { Component } from 'react'

class App extends Component {
  render() {
    return(
      <div>
        {
          this.props.language === 'JS' ? 
            <div>Language is JS</div> : 
            <div>Language is not JS</div>
        }
      </div>
    )
  }
}

you can use ternary in a declarative way:

import React, { Component } from 'react'
import Ternary from 'react-ternary'

class App extends Component {
  render() {
    return(
      <Ternary condition={this.props.language === 'JS'}>
        <div>Language is JS</div>     {/* first element will render if condition is true */}
        <div>Language is not JS</div> {/* second element will render if condition is false */ }
      </Ternary>
    )
  }
}
0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago