Code Monkey home page Code Monkey logo

react-reconditioned's Introduction

React Reconditioned

react-reconditioned logo

Declarative ternary operations for the masses!

NPM React Recon

THE DOCS

Install

npm install --save conditional-react


Description

It's pretty simple, really. Import the components and declare your logic!

Usage

<Conditional>
  <If>
    <p>IT'S TRUE πŸ—ΏπŸ—ΏπŸ—Ώ</p>
  </If>

  <Else>Darn it it's false!</Else>
</Conditional>

Examples

1. Simple If/Else

const [option, setoption] = useState(true);

return (
  <Conditional>
    <If>
      <p>IT'S TRUE πŸ—ΏπŸ—ΏπŸ—Ώ</p>
    </If>

    <Else>Darn it it's false!</Else>
  </Conditional>
);

2. Simple Switch Statement

const [option, setoption] = useState("initial value");

return (
  <Conditional condition={option}>
    <Switch>
      <Case value="initial value"></Case>

      <Default></Default>
    </Switch>
  </Conditional>
);

API

What does this thing provide?

Conditional React provides a utilitarian set of components that will make your life SO much easier !

Conditional

This is the overarching API exposed by this library that takes in the condition. Boolean for if/else statements and strings/objects whatever for switch statements.

If & Else

The two babies of the conditional component. If the statement resolves to true, it'll show the If component, else it will show the Else component and it's children.

Switch + Case & Default

The Switch component can only show one component at a time and resolves the condition from it's parent Conditional component. The case takes in a value and checks if the condition is equal to the condition in the parent Conditional component. The Switch component defaults to the Default component if no conditions are met.

License

MIT Β© alekangelov

react-reconditioned's People

Stargazers

Ines Germanski avatar Alek Angelov avatar Jamie robertson avatar

Watchers

James Cloos avatar Alek Angelov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.