Skip to content

chaoli23/react-children-utilities

 
 

Repository files navigation

React Children Utilities

npm version Build Status Dependency Status devDependency Status Coverage Status

Extended utils for React.Children opaque data structure.

Install

npm install --save react-children-utilities

Usage

Instead of requiring Children from React, require this one, it will extend existing capabilities from Children in your current React version.

var Children = require('react-children-utilities');

With ES6 modules

import Children from 'react-children-utilities';

Api documentation

Children.filter

Creates a new children array with all elements that pass the test implemented by the provided function.

Children.filter(children, callback)

Children.groupByType

Returns an object with keys that map each tag name to an array of children of that type, and a key that maps the rest of children.

Children.groupByType(children, tagNames[, restKey])

Children.deepMap

Creates a new children array with the results of calling a provided function on every element (and its children) in the provided children.

Children.deepMap(children, callback)

Children.deepForEach

Executes a provided function on every element (and its children) in the provided children.

Children.deepForEach(children, callback)

Children.deepFind

Returns the first element in the children (and its children) that satisfies the provided testing function.

Children.deepFind(children, callback)

Children.onlyText

Strips all html and returns only text nodes

Children.onlyText(children)

About

Extended utils for React.Children opaque data structure

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%