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