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

react-keyed-flatten-children

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-keyed-flatten-children - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

CHANGELOG.md

2

index.js

@@ -16,3 +16,3 @@ "use strict";

acc.push(react_1.cloneElement(node, {
key: keys.join(".") + "." + node.key
key: keys.concat(String(node.key)).join('.')
}));

@@ -19,0 +19,0 @@ }

@@ -31,3 +31,3 @@ /* Returns React children into an array, flattening fragments. */

cloneElement(node, {
key: `${keys.join(".")}.${node.key}`
key: keys.concat(String(node.key)).join('.')
})

@@ -34,0 +34,0 @@ );

{
"name": "react-keyed-flatten-children",
"version": "1.0.1",
"version": "1.1.0",
"description": "Flattens React children and fragments to an array with predictable and stable keys",

@@ -5,0 +5,0 @@ "main": "index.js",

# react-keyed-flatten-children
[![Build Status](https://travis-ci.org/grrowl/react-keyed-flatten-children.svg?branch=master)](https://travis-ci.org/grrowl/react-keyed-flatten-children)
Similar to [React's built-in `Children.toArray` method](https://reactjs.org/docs/react-api.html#reactchildrentoarray), this utility takes children and returns them as an array for introspection or filtering. Different from `toArray`, it will ensure element keys are unique, preserved, and stable between renders, and traverses into fragments and maintains their keys, too.
## getting started
```
npm install react-keyed-flatten-children
```
```
yarn add react-keyed-flatten-children
```
## why?

@@ -19,3 +31,3 @@

`react-keyed-flatten-children` is a drop-in replacement for `Children.toArray`.
`react-keyed-flatten-children` is a drop-in replacement for `Children.toArray`. In this example, instead of needing to rely on the child's array index, we can reference the key:

@@ -22,0 +34,0 @@ ```jsx

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