1.2.0 • Published 5 years ago
tsx-conditionals v1.2.0
TSX Conditionals
Example
tsx conditionals exposes two components:
For & If
Purpose
- Eliminate exposed control flow logic in your components
- Reduce mixing Javascript/Typescript and JSX/TSX in a view component
- Improve readability
For replaces:
{data.map(item => <Component key={item.key} />)}{data && data.map(item => <Component key={item.key} />)}
If replaces:
{open && <Component />}{open ? <ComponentA /> : <ComponentB />}
Props
For props:
data: T[] | nullrender: (item: T) => JSX.Element | React.FC
If props:
cond: booleanthen: JSX.ElementorElse: JSX.Element | null