JSXCOND
Installation
npm install jsxcond --save
Usage
if-else-then
_if (TEST_FORM, THEN_FORM, [ELSE_FORM])
- Common Usage
import React from 'react';import _if from 'jsxcond'Component{const condition = true;<div></div>}
- Only if, no else
import React from 'react';import _if from 'jsxcond'Component{const condition = true;<div></div>}
TEST_FORM
can be a function
import React from 'react';import _if from 'jsxcond'Component{const condition = true;<div></div>}
- Recommend using
() => ()
to have lazy eval(). HoweverTHEN_FORM
andELSE_FORM
are still supported.
import React from 'react';import _if from 'jsxcond'Component{const condition = true;<div></div>}
cond
if-else-then
_cond (STATEMENT1, STATEMENT2...)
STATEMENT can be array
, function
, common value
:
-
When it is a value, it will be returned immediately.
-
When it is a function, it will be evaluated and returned immediately.
-
When it is a array, the first value will be used as TEST_FORM, and the second will be used as THEN_FORM.
-
Common Usage
import React from 'react';import _cond from 'jsxcond'Component{const condition = 3<div>
TEST_FORM
can be a function
import React from 'react';import _cond from 'jsxcond'Componentconst condition = 3;{<div></div>}
License
MIT