Swap

Renders one of two things, picked by a boolean.

Usage

The first branch renders while swapOn is false, the second while it is true. Click the button.

tsx
<Swap.Boolean swapOn={isDark} components={[MdLightMode, MdDarkMode]} />

With props

Pass elements when the branches need props.

tsx
<Swap.Boolean swapOn={isPlaying} components={[<MdPlayArrow size={16} />, <MdPause size={16} />]} />

More than two branches

Use Switch.

Reference

Swap is a namespace: the component is Swap.Boolean.

proptypedefault
components?Renderable[][]the two branches: [when false, when true]
swapOn?booleanfalsetrue renders the second branch