JSPM

  • Created
  • Published
  • Downloads 52788
  • Score
    100M100P100Q155954F
  • License MIT

Extended utils for React.Children opaque data structure

Package Exports

  • react-children-utilities

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-children-utilities) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React Children Utilities

Gzip Bundle Size Build Status Test Coverage Status Known Vulnerabilities

npm version npm downloads

Extended utils for React.Children opaque data structure.

Installation

Available as a package and can be added to your application with npm or yarn after installing the peer dependency react

# with yarn
yarn add react-children-utilities react

# with npm
npm install --save react-children-utilities

Usage

This package extends the existing React.Children utilities, you can import it as a whole.

import React from 'react';
import Children from 'react-children-utilities';

const MyComponent = ({ children }) => {
  const onlySpans = Children.filter(children, (child) => child.type === 'span');
  return <div>{onlySpans}</div>;
};

Also you can import only the function you need

import React from 'react';
import { filter } from 'react-children-utilities';

const MyComponent = ({ children }) => {
  const onlySpans = filter(children, (child) => child.type === 'span');
  return <div>{onlySpans}</div>;
};

Api documentation

License

MIT (c) 2018 Fernando Pasik