1.0.2 • Published 6 years ago

bloom-conditionals v1.0.2

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

bloom-conditionals

Travis npm package Coveralls

A ReactJS conditional rendering higher order component.

Install

with npm

npm install bloom-conditionals

with yarn

yarn add bloom-conditionals

Usage

Simple static values test:

import { Condition, When, Else } from "bloom-conditionals";

const myComponent = (props) => {
    return <Condition test={props.someValue}>
        <When true>I am True</When>
        <When false>I am False</When>
        <Else>I render when no When or NotWhen renders</Else>
    </Condition>
}

Test specific values:

import { Condition, When, Else } from "bloom-conditionals";

const myComponent = (props) => {
    return <Condition test={props.someValue}>
        <When value={true}>I am True</When>
        <When value={false}>I am False</When>
        <Else>I render when no When or NotWhen renders</Else>
    </Condition>
}

Test using functions

import { Condition, When, Else } from "bloom-conditionals";

const myComponent = (props) => {
    return <Condition test={props.someValue}>
        <When value={v => v === true}>I am True</When>
        <When value={v => v === false}>I am False</When>
        <Else>I render when no When or NotWhen renders</Else>
    </Condition>
}
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago