react-tobe
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

React-Tobe

To be or not to be, that is the question !

Declarative condition in jsx

The Past

export default ({ loading }) => {
    return loading ? <span>is loading</span> : <span> done </span>
}

The Feature

With react-tobe, things are more react.

import { Choose, Tobe, OrNot } from 'react-tobe'
export default ({ loading }) => {
    return (
        <Choose condition={loading}>
            <Tobe>is loading</Tobe>
            <OrNot>done</OrNot>
        </Choose>
    )
}

And it's easier to debug on the react devtools for conditional rendering!

Lazy Rendering

With functional child component, element create can be deferred to specific branch rendering!

import { Choose, Tobe, OrNot } from 'react-tobe'
export default ({ loading }) => {
    return (
        <Choose condition={loading}>
            <Tobe>is loading</Tobe>
            <OrNot>
            {
                () => <span> done </span>
            }
            </OrNot>
        </Choose>
    )
}

Readme

Keywords

Package Sidebar

Install

npm i react-tobe

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

5.26 kB

Total Files

9

Last publish

Collaborators

  • joe06102