0.3.0 • Published 6 years ago

jsx-plus v0.3.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

jsx-plus

if/else/switch/case for jsx

Usage

import React from 'react';

import { IF, ELSE, SWITCH, CASE } from 'jsx-plus';

class Component extends React.Component {

  render(){
  
    let value = 2;
    
    return (
      <div>
      
        <IF test={value > 0}>
          value is greater than 0
          <ELSE/>
          value is equal or lesser than 0
        </IF>

        <SWITCH match={value}>
          <CASE test={0}>value is equal 0</CASE>
          <CASE test={1}>value is equal 1</CASE>
          <CASE test={2}>value is equal 2</CASE>
          {/* other children components without CASE is default */}
          unknown value
        </SWITCH>
        
      </div>
    );
  }

}

Components

IF

PropertyTypeDescription
testanycondition for test
tagstringdefault 'div'
idstring
classNamestring
styleobject

ELSE

no props

SWITCH

PropertyTypeDescription
matchanyvalue to match
tagstringdefault 'div'
idstring
classNamestring
styleobject

CASE

PropertyTypeDescription
testanyvalue to match
0.3.0

6 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago