https://github.com/birkir/react-children-addons
React Children Addons
https://github.com/birkir/react-children-addons
Last synced: 4 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 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-03T10:00:17.000Z (over 6 years ago)
- Last Synced: 2025-05-13T05:48:07.115Z (6 months ago)
- Language: TypeScript
- Size: 34.2 KB
- Stars: 7
- Watchers: 4
- 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
    
# react-children-addons
React 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.