Socket
Book a DemoInstallSign in
Socket

react-conditional-manager

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-conditional-manager

A react component that handles conditional logic in a more elegant manner.

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
45
-40%
Maintainers
1
Weekly downloads
 
Created
Source

react-conditional-manager

NPM version NPM license NPM total downloads NPM monthly downloads

A react component that handles conditional logic in a more elegant manner.

Install

npm install --save react-conditional-manager

Minimal Example

import React from "react";
import ConditionalManager from "react-conditional-manager";

const Example = props => {
    const conditions = [
        { loading: props.isLoading },
        { error: props.isError },
        { empty: props.conversations.length === 0 }
    ];

    return (
        <ConditionalManager conditions={conditions}>
            {{
                loading: <Loading />,
                error: <Error />,
                empty: <EmptyMessage message={"No conversations"} />,
                default: <InfiniteScroll renderRow={renderRow} />
            }}
        </ConditionalManager>
    );
};

export default Example;

Props

children: {}

  • The children prop is an object literal with the different renderable states.
  • isRequired

conditions: [{state: conditional}]

  • An array of states with an associated conditional.
  • First state to not appear in the array, becomes the default state and is rendered if all other conditionals return falsy.
  • If all states are listed and all conditionals return falsy then the ConditionalManager will render null.
  • default = []

renderedProps: {}

  • This object takes all properties and merges them as props into whichever state gets rendered.
  • default = {}

Keywords

react

FAQs

Package last updated on 17 Jul 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.