# react-clone

> Declarative element cloning for React

Latest version **1.0.0** (published 2016-01-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-clone
pnpm add react-clone
yarn add react-clone
bun add react-clone
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-01-30 |
| First published | 2016-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 32 |
| Maintainers | ryanflorence |
| Keywords | react, clone |

## Links

- npm: https://www.npmjs.com/package/react-clone
- Repository: https://github.com/ryanflorence/react-clone
- Issues: https://github.com/ryanflorence/react-clone/issues
- npm.io page: https://npm.io/package/react-clone

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-01-30

## README

React Clone
===========

Declarative element cloning for React.

### Installation

Using [npm](https://www.npmjs.com/):

    $ npm install react-clone

Then with a module bundler like [webpack](https://webpack.github.io/) that supports either CommonJS or ES2015 modules, use as you would anything else:

```js
// using an ES6 transpiler, like babel
import Clone from 'react-clone'

// not using an ES6 transpiler
var Clone = require('react-clone').default
```

The UMD build is also available on [npmcdn](https://npmcdn.com). You can find the library on `window.ReactClone`.

```html
<script src="https://npmcdn.com/react-clone/umd/ReactClone.min.js"></script>
```


### Usage

```js
const button = <button/>

// instead of this:
<div>
  {React.cloneElement(button, { onClick: handleClick })}
</div>

// you can keep it declarative like this:
<div>
  <Clone element={button} onClick={handleClick}/>
</div>

// it's mostly useful for passing extra props to children
// like animating the children of a React Router
// route component's children (gotta add that key)
<Clone
  element={this.props.children}
  key={location.pathname}
/>

// or iterating over children
React.Children.map(this.props.children, (child, index) => {
  return <Clone element={child} index={index}/>
})
```

---
_Source: https://npm.io/package/react-clone · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
