{"name":"react-lifecycles-compat","version":"3.0.4","description":"Backwards compatibility polyfill for React class components","main":"react-lifecycles-compat.cjs.js","module":"react-lifecycles-compat.es.js","license":"MIT","repository":{"type":"git","url":"git+https://github.com/reactjs/react-lifecycles-compat.git"},"scripts":{"build":"rollup -c","install:dependencies":"node install.js","lint":"eslint index.js","prepublish":"npm test","pretest":"npm run install:dependencies && npm run build","prettier":"prettier --write {index,test}.js","test":"jest test.js"},"files":["react-lifecycles-compat.cjs.js","react-lifecycles-compat.es.js","react-lifecycles-compat.js","react-lifecycles-compat.min.js"],"devDependencies":{"camelcase":"^5.0.0","chalk":"^2.3.0","eslint":"^4.16.0","eslint-config-es5":"^0.5.0","jest":"^22.1.4","jest-cli":"^22.1.4","prettier":"^1.10.2","rollup":"^0.57.1","rollup-plugin-replace":"^2.0.0","rollup-plugin-uglify":"^3.0.0"},"devEngines":{"node":"8.5 || 9.x"},"gitHead":"f457b78edcf85e44285ce8a840d133917de160da","bugs":{"url":"https://github.com/reactjs/react-lifecycles-compat/issues"},"homepage":"https://github.com/reactjs/react-lifecycles-compat#readme","_id":"react-lifecycles-compat@3.0.4","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},"dist":{"integrity":"sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==","shasum":"4f1a273afdfc8f3488a8c516bfda78f872352362","tarball":"http://registry-npm.ywwl.com/react-lifecycles-compat/download/react-lifecycles-compat-3.0.4.tgz","fileCount":8,"unpackedSize":29017,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa9asSCRA9TVsSAnZWagAA0/QP/ihj4D+KqjSzlN8JQAPc\ngYlNs42V/EhGRGu5NPEf6xdRR3x0kJm3V+/lRezf3zQZ/lNq7Zc3EB1iIYkw\nZOY0niXLFzAraLqkrGW4icumy0lOANNeUdPX9qgdna2vDR9W7MEo+RL+ALxe\nJ8a7TGP+XoV+Eu+hhhh5bKlKjoo3H0c8Vifhd2HNTmv7as03bAimaYHM6hpQ\nigKiKvJ+96pkVVonu/fUVfJ6lzvsmd4PO/kiztfzjY2urzghBSWCmTbTGfjW\n4Yskn8ux8flv3Gvn7aOWdvdDSzRD1YF/kE0xYg7YpQLC/ewV3YK2N4yl7fRu\nV0ZJiAbwcWydAYtepEuTbDAsf1QaRrQkBsxedltgsy9YHwCWWDWNH7FGWls3\n43IB74H9A/930cTp4pu5vJgLFmvgTXoOriiJN9qr28G1PzkU/JF+rBO9k6nC\nosk5AkbcDDNHkS18SF0YpFnWL07A5AzkkZL7hYxQ+P8Ge4OloKFz6QHxt8Sn\nSe3Xutp49SFoEmKcCiaj/mjldASdYsh+07v6Vc/pE5l3AwJddmAmoTel+sVy\n0JALkAjNI11TKTZGpR3axqyOk31AaymsD60jKV2laKm6Ig7vK7Dp3RW7vOiH\n2HhTRkn78yniyi0FdiBEulASpMEcw4IrjAZ97JVOXodmFbvqdKhBCTruC40S\n64Yx\r\n=zkyz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEnoyGmU723ZAqWK1W/mYrLnZMSJBztMx65Zs8uobzi4AiBLThGbpRfCmxqxCeMuh83KX3qKfoS+rdra0RgWTFLqgg=="}],"size":5999,"noattachment":false,"key":"/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz"},"maintainers":[{"email":"acdlite@me.com","name":"acdlite"},{"email":"briandavidvaughn@gmail.com","name":"brianvaughn"},{"email":"opensource+npm@fb.com","name":"fb"},{"email":"flarnie.npm@gmail.com","name":"flarnie"},{"email":"dan.abramov@gmail.com","name":"gaearon"},{"email":"npm@sophiebits.com","name":"sophiebits"},{"email":"dg@domgan.com","name":"trueadm"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-lifecycles-compat_3.0.4_1526049554207_0.535416919843893"},"_hasShrinkwrap":false,"readme":"# react-lifecycles-compat\n\n## What is this project?\n\nReact version 17 will deprecate several of the class component API lifecycles: `componentWillMount`, `componentWillReceiveProps`, and `componentWillUpdate`. (Read the [Update on Async rendering blog post](https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html) to learn more about why.) A couple of new lifecycles are also being added to better support [async rendering mode](https://reactjs.org/blog/2018/03/01/sneak-peek-beyond-react-16.html).\n\nTypically, this type of change would require third party libraries to release a new major version in order to adhere to semver. However, the `react-lifecycles-compat` polyfill offers a way to use the new lifecycles with older versions of React as well (0.14.9+) so no breaking release is required. This enables shared libraries to support both older and newer versions of React simultaneously.\n\n## How can I use the polyfill\n\nFirst, install the polyfill from NPM:\n```sh\n# Yarn\nyarn add react-lifecycles-compat\n\n# NPM\nnpm install react-lifecycles-compat --save\n```\n\nNext, update your component and replace any of the deprecated lifecycles with new ones introduced with React 16.3. (Refer to the React docs for [examples of how to use the new lifecycles](https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html).)\n\nLastly, use the polyfill to make the new lifecycles work with older versions of React:\n```js\nimport React from 'react';\nimport {polyfill} from 'react-lifecycles-compat';\n\nclass ExampleComponent extends React.Component {\n  static getDerivedStateFromProps(nextProps, prevState) {\n    // Normally this method would only work for React 16.3 and newer,\n    // But the polyfill will make it work for older versions also!\n  }\n\n  getSnapshotBeforeUpdate(prevProps, prevState) {\n    // Normally this method would only work for React 16.3 and newer,\n    // But the polyfill will make it work for older versions also!\n  }\n\n  // render() and other methods ...\n}\n\n// Polyfill your component so the new lifecycles will work with older versions of React:\npolyfill(ExampleComponent);\n\nexport default ExampleComponent;\n```\n\n## Which lifecycles are supported?\n\nCurrently, this polyfill supports [static `getDerivedStateFromProps`](https://reactjs.org/docs/react-component.html#static-getderivedstatefromprops) and [`getSnapshotBeforeUpdate`](https://reactjs.org/docs/react-component.html#getsnapshotbeforeupdate)- both introduced in version 16.3.\n\n## Validation\n\nNote that in order for the polyfill to work, none of the following lifecycles can be defined by your component: `componentWillMount`, `componentWillReceiveProps`, or `componentWillUpdate`.\n\nNote also that if your component contains `getSnapshotBeforeUpdate`, `componentDidUpdate` must be defined as well.\n\nAn error will be thrown if any of the above conditions are not met.","publish_time":1526049554276,"_cnpm_publish_time":1526049554276,"dist-tags":{"latest":"3.0.4","next":"1.1.1","v-2":"2.0.2"}}