A lightweight React component for joining multiple components in a grammatically correct way.
A lightweight React component for joining multiple components in a grammatically correct way. Joins
components using commas, "and", "&", "or", or any other term you specify.
Written in Typscript with zero dependencies.
``sh`
yarn add react-and
npm install --save react-and
ReactAnd accepts any number of children and will render them with the correct grammar.
`JSX`
{[
'apples',
'oranges',
'bananas',
]}
Renders as:
> apples, oranges, and bananas
You can pass any valid React components as children:
Renders as:
> oranges
This is the string to be used to join the last child when there is more than one child. Default: "and".
`JSX`
{[
'apples',
'oranges',
]}
Renders as:
> apples and/or oranges
Determines whether an Oxford comma will be used when joining the items. Default: true.
`JSX``
{[
'apples',
'oranges',
'bananas',
]}
Renders as:
> apples, oranges and bananas
https://lhansford.github.io/react-and/
Licensed under MIT.