{"name":"react-lifecycles-compat","version":"1.0.0","description":"Backwards compatibility polyfill for React class components","main":"index.js","license":"MIT","scripts":{"test":"jest test.js","build:dev":"NODE_ENV=development webpack","build:prod":"NODE_ENV=production webpack","build":"npm run build:dev && npm run build:prod","lint":"eslint index.js","postinstall":"node install.js","prepublish":"npm test && npm run build","prettier":"prettier --write {index,test}.js"},"files":["index.js","react-lifecycles-compat.js","react-lifecycles-compat.min.js"],"dependencies":{"webpack":"^2"},"devDependencies":{"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"},"devEngines":{"node":"8.5 || 9.x"},"gitHead":"1e650f49203035e4f9de994cd4be80f63c267cea","_id":"react-lifecycles-compat@1.0.0","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},"dist":{"integrity":"sha512-Iphc2tsVyT++ETw5PYKWiEcrPt+Dz4tznku9Vd5mO6PClqUin85Jp9vKoaHRuZKR9IMrnfuXaU4fN3U5N4Ftiw==","shasum":"539f7eaed465987d17f0af64c97c587c36c7566e","tarball":"http://registry-npm.ywwl.com/react-lifecycles-compat/download/react-lifecycles-compat-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsXrTmuYnRnP1UaeQ+vn+bYgg2rS7lYxMWhlSWpVx5kgIhALNEv/4giT5/FGbWdWnpLm6FTNxY6Jp0vvW2+cKRtUzf"}],"size":4956,"noattachment":false,"key":"/react-lifecycles-compat/-/react-lifecycles-compat-1.0.0.tgz"},"maintainers":[{"email":"briandavidvaughn@gmail.com","name":"brianvaughn"},{"email":"dg@domgan.com","name":"trueadm"},{"email":"flarnie.npm@gmail.com","name":"flarnie"},{"email":"npm@sophiebits.com","name":"sophiebits"},{"email":"acdlite@me.com","name":"acdlite"},{"email":"opensource+npm@fb.com","name":"fb"},{"email":"dan.abramov@gmail.com","name":"gaearon"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-lifecycles-compat-1.0.0.tgz_1517421592673_0.1656304041389376"},"deprecated":"getSnapshotBeforeUpdate() poylfill did not properly handle falsy values. Use 1.1.4+ instead.","directories":{},"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":1517421593588,"_cnpm_publish_time":1517421593588,"dist-tags":{"latest":"3.0.4","next":"1.1.1","v-2":"2.0.2"}}