@garmingo/join-react
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Join React

Extends the Array prototype to allow joining react elements similar to strings

Installation

npm install @garmingo/join-react

Usage

joinReact can be used by either importing the module or by importing the prototype extension directly.

Importing the function

import { joinReact } from '@garmingo/join-react';

const elements = [
    <div>1</div>,
    <div>2</div>,
    <div>3</div>,
];

const joinedElements = joinReact(elements, <div>Separator</div>);

Importing the Component

import { JoinReact } from '@garmingo/join-react';

const elements = [
    <div>1</div>,
    <div>2</div>,
    <div>3</div>,
];

<JoinReact elements={elements} separator={<div>Separator</div>} />

Importing the prototype extension

import '@garmingo/join-react';

const elements = [
    <div>1</div>,
    <div>2</div>,
    <div>3</div>,
];

const joinedElements = elements.joinReact(<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>

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @garmingo/join-react

Weekly Downloads

2

Version

2.0.3

License

MIT

Unpacked Size

16.1 kB

Total Files

9

Last publish

Collaborators

  • therealfloatdev
  • garmingo-management