React Clone
Declarative element cloning for React.
Installation
Using npm:
$ npm install react-clone
Then with a module bundler like webpack that supports either CommonJS or ES2015 modules, use as you would anything else:
// using an ES6 transpiler, like babel // not using an ES6 transpilervar Clone = default
The UMD build is also available on npmcdn. You can find the library on window.ReactClone
.
Usage
const button = <button/> // instead of this:<div> React</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=thispropschildren key=locationpathname/> // or iterating over childrenReactChildren