New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-pattern

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-pattern

A React pattern matching component for conditional renders

latest
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

React Pattern

A React pattern matching component for conditional rendering.

Usage

First install the component.

npm install --save react-pattern

Then, import it and use it.

import React from 'react'
import Switch from 'react-pattern'

const { Case } = Switch

const App = ({ isFetching, error }) => (
  <Switch value={isFetching}>
    <Case when={true}>
      <p>Is loading the data</p>
    </Case>
    <Case default>
      <Switch value={typeof error}>
        <Case when="object">
          {() => <p>{error.message}</p>}
        </Case>
        <Case default>
          <p>App loaded without errors.</p>
        </Case>
      </Switch>
    </Case>
  </Switch>
)

FAQs

Package last updated on 08 Nov 2017

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