1.2.0 • Published 4 years ago

tsx-conditionals v1.2.0

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

TSX Conditionals

Example

Codesandbox

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[] | null
  • render: (item: T) => JSX.Element | React.FC

If props:

  • cond: boolean
  • then: JSX.Element
  • orElse: JSX.Element | null
1.2.0

4 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago