join-react 2.0.0
Install from the command line:
Learn more about npm packages
$ npm install @garmingo/join-react@2.0.0
Install via package.json:
"@garmingo/join-react": "2.0.0"
About this version
Extends the Array prototype to allow joining react elements similar to strings
npm install @garmingo/join-react
joinReact can be used by either importing the module or by importing the prototype extension directly.
import { joinReact } from '@garmingo/join-react';
const elements = [
<div>1</div>,
<div>2</div>,
<div>3</div>,
];
const joinedElements = joinReact(elements, <div>Separator</div>);
import '@garmingo/join-react';
const elements = [
<div>1</div>,
<div>2</div>,
<div>3</div>,
];
const joinedElements = elements.join(<div>Separator</div>);
Now joinedElements
will be a react element containing the following:
<div>1</div>
<div>Separator</div>
<div>2</div>
<div>Separator</div>
<div>3</div>