This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

conditional-react

0.1.0 • Public • Published

conditional-react

Conditional React Rendering for better code readability

Without Conditional

render() {
  return (
    <div>
      <h1>Title</h1>
      {
        this.state.list.length > 0 && (
          <h1>List</h1>
          <List data={this.state.list} />
        )
      }
 
      {
        this.state.bool 
        ? <h1>Bool is true</h1>
        : null
      }
    </div>
  );
}

With Conditional

import {Conditional} from 'conditional-react';
 
render() {
  return (
    <div>
      <h1>Title</h1>
      
      <Conditional if={this.state.list.length > 0}>
        <h1>List</h1>
        <List data={this.state.list} />
      </Conditional>
 
      <Conditional if={this.state.bool}>
        <h1>Bool is true</h1>
      </Conditional>
    </div>
  );
}

Package Sidebar

Install

npm i conditional-react

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

4.04 kB

Total Files

4

Last publish

Collaborators

  • benjrei