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

react-simple-conditional

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-simple-conditional

A very simple conditional component for react and react native

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by1000%
Maintainers
1
Weekly downloads
 
Created
Source

Conditional render component for React and React Native

This simple conditional components only renders its children if the condition prop has a value that is true or truthy in JavaScript. If the condition prop has a value that interpretes as false, nothing (null) will be rendered.

The component renders nothing by itself, it uses React Fragments . All the props and children that you supply to the component gets passed to the div.

Usage:

To istall the component simply run:

npm install --save react-simple-conditional

Import it using:

import Conditional from 'react-simple-conditional'

Use it in JSX:

    <Conditional condition={someCondition}>
        <p>This will be rendered if 'someCondition' is true</p>
    </Conditional>

Full Example:

    import React, { Component } from 'react';
    import Conditional from 'react-simple-conditional';
    class App extends Component {
        state={
            renderCondition:true
        }
    render() {
        return (
            <Conditional 
            condition={this.state.renderCondition}>
                <h1>Hello World</h1>
            </Conditional>
        );
    }
    }

    export default App;

License:

This project is distributed under the MIT License

Keywords

FAQs

Package last updated on 11 Nov 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

  • 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