1.0.3 • Published 3 years ago

react-logic-components v1.0.3

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

react-logic-components

This library add components that simulates If, For and other statements

NPM JavaScript Style Guide

Install

npm install --save react-logic-components

Usage

import React from 'react'

import { Case, Default, If, Switch, For } from 'react-logic-components'

const App = () => {
  const ifCondition = true

  return (
    <div>
      <If condition={false}>
        <p>This if component should not render </p>
      </If>

      <If condition={ifCondition}>
        <p>This if component should render</p>
      </If>

      <Switch value={2}>
        <Case value={1}>
          <p> Value 1 should not render</p>
        </Case>
        <Case value={2}>
          <p>Value 2 should render</p>
        </Case>
        <Default>
          <p>Default value should not render</p>
        </Default>
      </Switch>

      <For
        start={2}
        maxValue={5}
        element={(props) => <p>{props.index}. From 2 to 5 should be render</p>}
      />
    </div>
  )
}

export default App

License

MIT © AlStinson

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago