Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-knit

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-knit

> Join arrays of data like a pro in [React](https://reactjs.org)

  • 1.0.5
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-knit Build Status

Join arrays of data like a pro in React

Install

$ npm install react-knit

Usage

import React from 'react';
import Knit, {
  withSeparator,
  withOxfordComma,
  withTag,
} from 'react-knit';

const App = props => (
  <React.Fragment>
    <Knit items={['Joe', 'Jane', 'John']} /> // Joe, Jane, John
    <Knit wrap="p" items={['Joe', 'Jane', 'John']} /> // <p>Joe, Jane, John</p>
    <Knit wrap="p" items={['Joe', 'Jane', 'John']} render={withOxfordComma()} /> // <p>Joe, Jane, and John</p>
    <Knit wrap="p" items={['Joe', 'Jane', 'John']} render={withOxfordComma('og')} /> // <p>Joe, Jane, og John</p>
    <Knit items={['Joe', 'Jane', 'John']} render={withTag('span')} /> // <span>Joe<span><span>Jane</span><span><span>John</span>
    <Knit items={['Joe']} render={withTag('span', {className:'user'})} /> // <span class="user">Joe<span>
  </React.Fragment>
);

Props

items

Type: array

Array of data to process. Can be strings or React elements, or anything.

render

Type: func

A render function. There are some embedded render functions that should cover most use cases:

withTag(tagName, attributes)
withSeparator(separator)
withOxfordComma(word)
wrap

Type: string element

Wrap the output in a tag/component

License

MIT © Raymond Julin

Keywords

FAQs

Package last updated on 17 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc