react-select-case

1.0.1 • Public • Published

react-select-case

A simple way to do select case logic inline in a react component

Frequently react components want to render different content based on a value of an expression. This can be done with if statements and variables, but that is often overkill for simple uses. This library provides a simple API for this kind of logic.

Install

npm install --save react-select-case

An Example

This will report whether the time in epoch millis was odd or even when the component was rendered.

<Select on={ (+new Date) % 2 }>
  <Case when={ 0 }>
    Time is even
  </Case>
  <Case when={ 1 }>
    Time is odd
  </Case>
</Select>

Readme

Keywords

none

Package Sidebar

Install

npm i react-select-case

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

170 kB

Total Files

16

Last publish

Collaborators

  • segfaultx64