babel-plugin-jsx-control-statements-macros
TypeScript icon, indicating that this package has built-in type declarations

1.1.0-v2.2 • Public • Published

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>
)

Package Sidebar

Install

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

Weekly Downloads

2

Version

1.1.0-v2.2

License

MIT

Unpacked Size

25.5 kB

Total Files

19

Last publish

Collaborators

  • akilan_sengottaiyan