Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-jsx-cases-control

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-jsx-cases-control

A babel plugin extending the JSX syntax with easy to use conditional statement

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-jsx-cases-control

A babel plugin extending the JSX syntax with easy to use conditional statement

Usage

Simple usage

<div if={this.div.will.only.exist.if.this.statement.is.true}>
    {console.log('This will not even execute when the condition evaluates false')}
</div>

Multiple branches

<Cases>
    <div if={first.condition}>
        This is shown if the first condition matches
    </div>
    <div if={second.condition}>
        This is shown if the first condition fail to match but second condition matches
    </div>
    <div>
        This is shown when all above condition doesn't match
    </div>
    <div>
        This is never shown
    </div>
</Cases>

Case switch

<Cases of={the.number}>
    <div if={0}>
        the number is 0
    </div>
    <div if={1}>
        the number is 1
    </div>
    <div if="hello">
        the number is actually a string
    </div>
    <div>
        the number is nothing above
    </div>
    <div>
        This is never shown
    </div>
</Cases>

Cave at

The Cases tag is converted to something like {condition ? consequent : alternate} so you can not set key or ref on this. Just set properties on the branch tags instead.

Tip

You may set if on the Cases tag too.

FAQs

Package last updated on 01 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc