{"_id":"react-clone-referenced-element","_rev":"260683","name":"react-clone-referenced-element","description":"Clones a React element while preserving its original ref","dist-tags":{"latest":"1.1.1"},"maintainers":[{"name":"ide","email":"ide+npm@jameside.com"}],"time":{"modified":"2021-06-03T16:44:38.000Z","created":"2016-01-14T05:04:28.233Z","1.1.1":"2021-05-09T00:36:46.431Z","1.1.0":"2018-09-12T19:00:28.735Z","1.0.1":"2016-01-19T09:40:01.709Z","1.0.0":"2016-01-14T05:04:28.233Z"},"users":{"brien-crean":true},"author":{"name":"James Ide"},"repository":{"type":"git","url":"git+https://github.com/ide/react-clone-referenced-element.git"},"versions":{"1.1.1":{"name":"react-clone-referenced-element","version":"1.1.1","description":"Clones a React element while preserving its original ref","main":"cloneReferencedElement.js","types":"cloneReferencedElement.d.ts","scripts":{"test":"jest"},"prettier":{"singleQuote":true},"repository":{"type":"git","url":"git+https://github.com/ide/react-clone-referenced-element.git"},"keywords":["react","clone","element"],"author":{"name":"James Ide"},"license":"MIT","bugs":{"url":"https://github.com/ide/react-clone-referenced-element/issues"},"homepage":"https://github.com/ide/react-clone-referenced-element#readme","devDependencies":{"jest":"^26.6.3","react":"^17.0.2","react-test-renderer":"^17.0.2"},"gitHead":"a8031973b7c1ad0cb8654f8002d7b0bc4ac9637c","_id":"react-clone-referenced-element@1.1.1","_nodeVersion":"16.0.0","_npmVersion":"7.10.0","dist":{"shasum":"8d76727dc0459788e461741e804a512d20757381","size":2382,"noattachment":false,"key":"/react-clone-referenced-element/-/react-clone-referenced-element-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/react-clone-referenced-element/download/react-clone-referenced-element-1.1.1.tgz"},"_npmUser":{"name":"ide","email":"ide+npm@jameside.com"},"directories":{},"maintainers":[{"name":"ide","email":"ide+npm@jameside.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-clone-referenced-element_1.1.1_1620520606240_0.016420203277498047"},"_hasShrinkwrap":false,"publish_time":1620520606431,"_cnpm_publish_time":1620520606431},"1.1.0":{"name":"react-clone-referenced-element","version":"1.1.0","description":"Clones a React element while preserving its original ref","main":"cloneReferencedElement.js","types":"cloneReferencedElement.d.ts","repository":{"type":"git","url":"git+https://github.com/ide/react-clone-referenced-element.git"},"keywords":["react","clone","element"],"author":{"name":"James Ide"},"license":"MIT","bugs":{"url":"https://github.com/ide/react-clone-referenced-element/issues"},"homepage":"https://github.com/ide/react-clone-referenced-element#readme","gitHead":"694a7b2e77e0d8bbe68ecf08e03e87c12ac422ec","_id":"react-clone-referenced-element@1.1.0","_npmVersion":"6.4.1","_nodeVersion":"8.11.3","_npmUser":{"name":"ide","email":"ide+npm@jameside.com"},"dist":{"shasum":"9cdda7f2aeb54fea791f3ab8c6ab96c7a77d0158","size":2159,"noattachment":false,"key":"/react-clone-referenced-element/-/react-clone-referenced-element-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/react-clone-referenced-element/download/react-clone-referenced-element-1.1.0.tgz"},"maintainers":[{"name":"ide","email":"ide+npm@jameside.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-clone-referenced-element_1.1.0_1536778828571_0.29384847761117805"},"_hasShrinkwrap":false,"publish_time":1536778828735,"_cnpm_publish_time":1536778828735},"1.0.1":{"name":"react-clone-referenced-element","version":"1.0.1","description":"Clones a React element while preserving its original ref","main":"cloneReferencedElement.js","repository":{"type":"git","url":"git+https://github.com/ide/react-clone-referenced-element.git"},"keywords":["react","clone","element"],"author":{"name":"James Ide"},"license":"MIT","bugs":{"url":"https://github.com/ide/react-clone-referenced-element/issues"},"homepage":"https://github.com/ide/react-clone-referenced-element#readme","gitHead":"fe8873dad29f6beba7168cafe733d48ea26a1cc0","_id":"react-clone-referenced-element@1.0.1","scripts":{},"_shasum":"2bba8c69404c5e4a944398600bcc4c941f860682","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.3.0","_npmUser":{"name":"ide","email":"ide+npm@jameside.com"},"dist":{"shasum":"2bba8c69404c5e4a944398600bcc4c941f860682","size":2283,"noattachment":false,"key":"/react-clone-referenced-element/-/react-clone-referenced-element-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/react-clone-referenced-element/download/react-clone-referenced-element-1.0.1.tgz"},"maintainers":[{"name":"ide","email":"ide+npm@jameside.com"}],"directories":{},"publish_time":1453196401709,"_cnpm_publish_time":1453196401709,"_hasShrinkwrap":false},"1.0.0":{"name":"react-clone-referenced-element","version":"1.0.0","description":"Clones a React element while preserving its original ref","main":"cloneReferencedElement.js","repository":{"type":"git","url":"git+https://github.com/ide/react-clone-referenced-element.git"},"keywords":["react","clone","element"],"author":{"name":"James Ide"},"license":"MIT","bugs":{"url":"https://github.com/ide/react-clone-referenced-element/issues"},"homepage":"https://github.com/ide/react-clone-referenced-element#readme","peerDependencies":{"react":"*"},"gitHead":"d387553df46d5d1e8f3e36c35a26efa4d25c4c2a","_id":"react-clone-referenced-element@1.0.0","scripts":{},"_shasum":"10cfb2efc20188a0a8fd21d3c45576ae4fa46b04","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.3.0","_npmUser":{"name":"ide","email":"ide+npm@jameside.com"},"dist":{"shasum":"10cfb2efc20188a0a8fd21d3c45576ae4fa46b04","size":2293,"noattachment":false,"key":"/react-clone-referenced-element/-/react-clone-referenced-element-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/react-clone-referenced-element/download/react-clone-referenced-element-1.0.0.tgz"},"maintainers":[{"name":"ide","email":"ide+npm@jameside.com"}],"directories":{},"publish_time":1452747868233,"_cnpm_publish_time":1452747868233,"_hasShrinkwrap":false}},"readme":"# cloneReferencedElement for React [![Tests](https://github.com/ide/react-clone-referenced-element/actions/workflows/tests.yaml/badge.svg)](https://github.com/ide/react-clone-referenced-element/actions/workflows/tests.yaml) [![codecov](https://codecov.io/gh/ide/react-clone-referenced-element/branch/main/graph/badge.svg?token=FwQSK9uKF7)](https://codecov.io/gh/ide/react-clone-referenced-element)\n\n\nThis is a version of `React.cloneElement` that preserves the original element's callback ref even if you specify a new callback ref for the clone.\n\nThis library is written for components that use callback refs.\n\n## Installation\n\nInstall this module from npm:\n```sh\nnpm install --save react-clone-referenced-element\n```\n\nThis library is written in ES2018. Your JavaScript runtime must support [trailing commas in function calls](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#trailing_commas_in_functions) and [object spread properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#spread_in_object_literals). All modern browsers since 2018 support these features.\n\nYou will also need to transform or define a global variable named `__DEV__`.\n\n## Usage\n\nThe signature of `cloneReferencedElement` is the same as that of `React.cloneElement`. However, when using callback refs, it will preserve the ref on the original component if there is one.\n\n```js\nconst original =\n  <Component ref={component => {\n    console.log('Running the original ref handler');\n  }} />;\nconst clone = cloneReferencedElement(original, {\n  ref(component) {\n    console.log('Running the clone ref handler');\n  },\n});\n```\n\nWhen the component is mounted, the console will display:\n```\nRunning the clone ref handler\nRunning the original ref handler\n```\n","_attachments":{},"homepage":"https://github.com/ide/react-clone-referenced-element#readme","bugs":{"url":"https://github.com/ide/react-clone-referenced-element/issues"},"license":"MIT"}