Socket
Socket
Sign inDemoInstall

react-conditionally-render

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-conditionally-render

Reduce mental overhead by wrapping conditional logic in a react component


Version published
Weekly downloads
11K
decreased by-11.18%
Maintainers
1
Weekly downloads
 
Created
Source

Introduction

Readability is important, and conditional renders often introduce a complexity that make it difficult to follow what is going on. This component aims to solve that by creating a readable interface in the form of a react component

Usage

Simple usage:

import Profile from './Profile'
import AnonymousProfile from './AnonymousProfile'

<ConditionallyRender
  condition={loggedIn}
  show={<Profile />}
  elseShow={<AnonymousProfile />}
/>

Usage with functions:

import Profile from './Profile'
import AnonymousProfile from './AnonymousProfile'

const renderProfile = () => {
 return <Profile />
}

const renderAnonymousProfile = () => {
    return <AnonymousProfile />
}

<ConditionallyRender
  condition={loggedIn}
  show={renderProfile}
  elseShow={renderAnonymousProfile}
/>

FAQs

Package last updated on 09 Jul 2021

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