Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/birkir/react-children-addons
React Children Addons
https://github.com/birkir/react-children-addons
Last synced: about 2 months ago
JSON representation
React Children Addons
- Host: GitHub
- URL: https://github.com/birkir/react-children-addons
- Owner: birkir
- License: mit
- Created: 2018-10-28T05:53:05.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-03T10:00:17.000Z (over 5 years ago)
- Last Synced: 2024-10-28T15:59:41.543Z (2 months ago)
- Language: TypeScript
- Size: 34.2 KB
- Stars: 7
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - react-children-addons - React Children Addons (TypeScript)
README
![](https://img.shields.io/npm/v/react-children-addons.svg?&style=flat-square) ![](https://img.shields.io/bundlephobia/min/react-children-addons.svg?&style=flat-square) ![](https://img.shields.io/npm/l/react-children-addons.svg?&style=flat-square) ![](https://img.shields.io/david/birkir/react-children-addons.svg?&style=flat-square) ![](https://img.shields.io/npm/dw/react-children-addons.svg?&style=flat-square)
# react-children-addonsReact children utilities and addons
```bash
npm install react-children-addons -S# or
yarn add react-children-addons -S
```## API Methods
- [toFlatArray](#toflatarray)
- [mapFlat](#mapflat)### toFlatArray
Takes children and flattens all React.Fragments into a single array
```jsx
import { toFlatArray } from 'react-children-addons';function List({ children }) {
console.log(toFlatArray(children));
}
<>
>
```
```jsx
[
```
### mapFlat
Same as `toFlatArray` but with a map function
```jsx
import React from 'react';
import { mapFlat } from 'react-children-addons';
function List({ children }) {
return (
{mapFlat(children, child => React.cloneElement(child, { className: 'link' }))}
);
}
<>
>
<>
>
```
```html
- Item
- Another Item
- Nested Item
```
## Todo
Add tests, changelog and more ideas for addons.