README
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
replaces: For
{data.map(item => <Component key={item.key} />)}
{data && data.map(item => <Component key={item.key} />)}
replaces: If
{open && <Component />}
{open ? <ComponentA /> : <ComponentB />}
Props
props: For
data: T[] | null
render: (item: T) => JSX.Element | React.FC
props: If
cond: boolean
then: JSX.Element
orElse: JSX.Element | null