GithubHelp home page GithubHelp logo

afeiship / react-if-else Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 314 KB

If else logic component for react.

JavaScript 13.86% SCSS 0.43% HTML 8.22% CSS 40.44% TypeScript 37.05%
react if else condition logic ife

react-if-else's Introduction

react-if-else

If else logic component for react.

version license size download

installation

npm install -S @jswork/react-if-else

properties

Name Type Required Default Description
only bool false false If is only child.

usage

  1. import css
@import "~@jswork/react-if-else/dist/style.css";

// or use sass
@import "~@jswork/react-if-else/dist/style.scss";

// customize your styles:
$react-if-else-options: ()
  1. import js
import ReactDemokit from '@jswork/react-demokit';
import React from 'react';
import ReactDOM from 'react-dom';
import noop from '@jswork/noop';
import ReactIfElse from '@jswork/react-if-else';
import './assets/style.scss';

class App extends React.Component {
  state = {
    checked: false,
    value: false
  };
  render() {
    return (
      <ReactDemokit
        className="p-3 app-container"
        url="https://github.com/afeiship/react-if-else">
        <h1>Status: {String(this.state.value)}</h1>
        <p>
          <span
            onClick={() => {
              this.setState({ value: !this.state.value });
            }}>
            <input type="checkbox" onChange={noop} checked={this.state.value} />
            <strong>改变状态</strong>
          </span>
        </p>
        <p>
          <label>
            <input
              type="checkbox"
              value={this.state.checked}
              onChange={() => {
                this.setState({ checked: !this.state.checked });
              }}
            />
            点前面的切换
          </label>
        </p>
        <ReactIfElse virtual value={this.state.value}>
          <span>When Truthy</span>
          <span>When Falsly</span>
        </ReactIfElse>
        <ReactIfElse only value={this.state.checked}>
          <span>When checked, i will show!</span>
        </ReactIfElse>
      </ReactDemokit>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('app'));

documentation

todo

// will trigger error warning
<IfElse virtual value={item.to}>
  <Link to={item.to}>{item.label}</a>
  <strong>{item.label}</strong>
</IfElse>

license

Code released under the MIT license.

react-if-else's People

Contributors

afeiship avatar

Watchers

 avatar  avatar  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.