Skip to content

akilansengottaiyan/jsx-control-statements

 
 

Repository files navigation

JSX Control Statements with macros

This repository is the extension of jsx-control-statements with macros support.

It also supports the non macro version of the library

Installation :

npm i -D babel-plugin-macros

npm i -D babel-plugin-jsx-control-statements-macros

Usage :

import { If, For, With, Choose, When, Otherwise } from 'babel-plugin-jsx-control-statements-macros/macro'

const ExampleJsxControlStatements = () => (
  <If condition={true}>
      Rendered
  </If>
  <If condition={false}>
      Not Rendered
  </If>

  <For each="item" of={[1,2,3,4,5]}>
      <span key={item}>{item}</span>
  </For>
  
  <With foo={47} bar={'test'}>
      <span>{foo}</span>
      <span>{bar}</span>
  </With>

  <Choose>
      <When condition={false}>
          <span>IfBlock not rendered</span>
      </When>
      <When condition={true}>
          <span>ElseIfBlock rendered</span>
      </When>
      <Otherwise>
          <span>ElseBlock not rendered</span>
      </Otherwise>
  </Choose>
)

About

Neater If and For for React JSX with support for macros

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 97.9%
  • TypeScript 2.1%