npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

conditional-jsx

v1.0.6

Published

React components for conditional statements.

Downloads

40

Readme

conditional-jsx

Conditional statements for JSX, a nice replacement for ternaries or logical operators when conditionally rendering react components in JSX.

Table of contents

Functions

  • Case
  • If
  • IfElse
  • OnFalse
  • OnTrue
  • Satisfies
  • Switch
  • Unless
  • When

Functions

Case

Const Case(__namedParameters: { condition: any ; value: any }): any

Renders when its the condition supplied by its parent matches its value prop.

  • See also: Satisfies, Switch

function Case

Parameters

| Name | Type | | :------ | :------ | | __namedParameters | object | | __namedParameters.condition | any | | __namedParameters.value | any |

Returns: any

Defined in: index.js:102


If

Const If(__namedParameters: { condition: any }): any

Renders when its condition prop is truthy

  • Synonyms: When, OnTrue
  • See also: Unless, OnFalse

function If

Parameters

| Name | Type | | :------ | :------ | | __namedParameters | object | | __namedParameters.condition | any |

Returns: any

Defined in: index.js:32


IfElse

Const IfElse(__namedParameters: { condition: any }): any

Supplies its condition prop to all its children, use with OnTrue and OnFalse.

  • See also: OnTrue, OnFalse

Note:

  • Supports multiple OnTrue, OnFalse and/or other components as children.
  • It provides keys as best as it can to its children, but its better if they are provided beforehand.

function IfElse

Parameters

| Name | Type | | :------ | :------ | | __namedParameters | object | | __namedParameters.condition | any |

Returns: any

Defined in: index.js:69


OnFalse

Const OnFalse(__namedParameters: { condition: any }): any

Renders when its IfElse parent condition is falsy

  • Synonyms: Unless
  • See also: If, When, OnTrue

function OnFalse

Parameters

| Name | Type | | :------ | :------ | | __namedParameters | object | | __namedParameters.condition | any |

Returns: any

Defined in: index.js:10


OnTrue

Const OnTrue(__namedParameters: { condition: any }): any

Renders when its IfElse parent condition is truthy

  • Synonyms: If, When
  • See also: Unless, OnFalse

function OnTrue

Parameters

| Name | Type | | :------ | :------ | | __namedParameters | object | | __namedParameters.condition | any |

Returns: any

Defined in: index.js:21


Satisfies

Const Satisfies(__namedParameters: { condition: any ; predicate: (arg0: any) => boolean }): any

Renders when its the condition supplied by its parent matches its value prop.

  • See also: Case, Switch

function Satisfies

Parameters

| Name | Type | | :------ | :------ | | __namedParameters | object | | __namedParameters.condition | any | | __namedParameters.predicate | (arg0: any) => boolean |

Returns: any

Defined in: index.js:113


Switch

Const Switch(__namedParameters: { condition: any }): any

Supplies its condition prop to all its children, use with Case or Satisfies as children.

  • See also: Case, Satisfies

Note:

  • Supports multiple Case, Satisfies and/or other components as children.
  • Can also be used as IfElse, but the syntax is sub-optimal.
  • It provides keys as best as it can to its children, but its better if they are provided beforehand.

function Switch

Parameters

| Name | Type | | :------ | :------ | | __namedParameters | object | | __namedParameters.condition | any |

Returns: any

Defined in: index.js:92


Unless

Const Unless(__namedParameters: { condition: any }): any

Renders when its condition prop is falsy

  • Synonyms: OnFalse
  • See also: If, When, OnTrue

function Unless

Parameters

| Name | Type | | :------ | :------ | | __namedParameters | object | | __namedParameters.condition | any |

Returns: any

Defined in: index.js:52


When

Const When(__namedParameters: { condition: any }): any

Renders when its condition prop is truthy

  • Synonyms: If, OnTrue
  • See also: Unless, OnFalse

function When

Parameters

| Name | Type | | :------ | :------ | | __namedParameters | object | | __namedParameters.condition | any |

Returns: any

Defined in: index.js:42