{"bugs":{"url":"https://github.com/gaearon/react-hot-loader/issues"},"dist":{"shasum":"dced27e8e2400adb1690eb5b3a0a39b4e0b90615","tarball":"https://registry.npmjs.org/react-hot-loader/-/react-hot-loader-4.0.0-beta.23.tgz","fileCount":12,"integrity":"sha512-JjOdObe3fCUGzZwHoZsB8M7EWM525pv4gL1zo8mNjvw6S8+0Je92QYx/cOumzVdvDlaEvkw9vjJm1XPo2Ngz5Q==","signatures":[{"sig":"MEYCIQDHWyPfin6Jgd83Fecdth65rMN2I2GSsKwy3aHAa2x06QIhAMLLw2zTpycWMZG1J1rS5i0o3qgaCzyogsVC3LeiSBv7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":91189},"jest":{"transform":{"^.+\\.js$":"<rootDir>/testConfig/babel.js"},"setupFiles":["<rootDir>/testConfig/setupTests.js"],"moduleDirectories":["node_modules","<rootDir>"]},"main":"index.js","name":"react-hot-loader","files":["dist","index.js","babel.js","patch.js","react-hot-loader.d.ts"],"types":"react-hot-loader.d.ts","author":{"name":"Dan Abramov"},"readme":"# React Hot Loader\n\n[![Build Status][build-badge]][build] [![version][version-badge]][package]\n[![Code Coverage][coverage-badge]][coverage]\n[![MIT License][license-badge]][license]\n\n[![PRs Welcome][prs-badge]][prs] [![Chat][chat-badge]][chat]\n\n[![Watch on GitHub][github-watch-badge]][github-watch]\n[![Star on GitHub][github-star-badge]][github-star]\n\nTweak React components in real time ⚛️⚡️\n\nWatch\n**[Dan Abramov's talk on Hot Reloading with Time Travel](https://www.youtube.com/watch?v=xsSnOQynTHs).**\n\n## Install\n\n```\nnpm install react-hot-loader@next\n```\n\n> Note: You can safely install react-hot-loader as a regular dependency instead\n> of a dev dependency as it automatically ensures it is not executed in\n> production and the footprint is minimal.\n\n## Getting started\n\n1. Add `react-hot-loader/babel` to your `.babelrc`:\n\n```js\n// .babelrc\n{\n  \"plugins\": [\"react-hot-loader/babel\"]\n}\n```\n\n> Note: use `.compilerc` in case of Electron\n\n2. Mark your root component as _hot-exported_:\n\n```js\n// ./containers/App.js\nimport React from 'react'\nimport { hot } from 'react-hot-loader'\n\nconst App = () => <div>Hello World!</div>\n\nexport default hot(module)(App)\n```\n\nDo not use `hot` if you are using **parcel** bundler. It was designed for webpack.\n\n`Hot` accepts only React Component (Stateful or Stateless), resulting the `HotExported` variant of it.\nThe `hot` function will setup current module to _self-accept_ itself on reload, and will **ignore** all the changes, made for non-React components.\nYou may mark as much modules as you want. But `HotExportedComponent` **should be the only used export** of a _hot_-module.\n\n> Note: Please note how often we have used `exported` keyword. `hot` is for exports.\n\n> Note: does nothing in production mode, just passes App through.\n\n3. [Run Webpack with Hot Module Replacement](https://webpack.js.org/guides/hot-module-replacement/#enabling-hmr):\n\n```sh\nwebpack-dev-server --hot\n```\n\n## Recipes\n\n### Migrating from [create-react-app](https://github.com/facebookincubator/create-react-app)\n\n1. Run `npm run eject`\n2. Install React Hot Loader (`npm install --save-dev react-hot-loader`)\n3. In `config/webpack.config.dev.js`, add `'react-hot-loader/babel'` to Babel\n   loader configuration. The loader should now look like:\n\n```js\n  {\n    test: /\\.(js|jsx)$/,\n    include: paths.appSrc,\n    loader: require.resolve('babel-loader'),\n    options: {\n      // This is a feature of `babel-loader` for Webpack (not Babel itself).\n      // It enables caching results in ./node_modules/.cache/babel-loader/\n      // directory for faster rebuilds.\n      cacheDirectory: true,\n      plugins: ['react-hot-loader/babel'],\n    },\n  }\n```\n\n4. Mark your App (`src/index.js`) as _hot-exported_:\n\n```js\n// ./containers/App.js\nimport React from 'react'\nimport { hot } from 'react-hot-loader'\n\nconst App = () => <div>Hello World!</div>\n\nexport default hot(module)(App)\n```\n\n### Migrating from [create-react-app](https://github.com/facebookincubator/create-react-app) without ejecting\n\nUsers [reports](https://github.com/gaearon/react-hot-loader/pull/729#issuecomment-354097936), that it is possible to use [react-app-rewire-hot-loader](https://github.com/cdharris/react-app-rewire-hot-loader) to setup React-hot-loader without ejecting.\nFollow [these code examples](https://github.com/Grimones/cra-rhl/commit/4ed74af2dc649301695f67df05a12f210fb7820c) to repeat the approach.\n\n### TypeScript\n\nWhen using TypeScript, Babel is not required, but RHL will not work without it.\nJust add babel-loader into your webpack configuration, with RHL-only config.\n\n```js\n{\n  test: /\\.tsx?$/,\n  use: [\n    {\n      loader: 'babel-loader',\n      options: {\n        babelrc: true,\n        plugins: ['react-hot-loader/babel'],\n      },\n    },\n    'ts-loader', // (or awesome-typescript-loader)\n  ],\n}\n```\n\nYou **also have to modify tsconfig**\n\n```json\n{\n   ...\n   \"module\": \"commonjs\", // module should be commonjs, as long \"imports\" in TS and Babel works differently.\n   \"target\": \"es6\", // target should be es6, or RHL will be unable to change some class members\n   ...\n}\n```\n\nYet again - module = es6 **will not work**.\n\n### Parcel Bundler\n\nParcel's HRM is a bit different.\n\n* Do not use `hot` (v4) to make Components hot-reloadable.\n* Use `AppContainer` + `module.hot.accept` (v3), follow the version 3 guide lines.\n\nDo the same for any other bundler or framework. `hot` is not a silver bullet. Sometimes it may break the stuff.\nIf something is not working (absolutely) - remove the `hot`.\n\n### Electron\n\nTo enable HRM on webpack, just enable it\n\n```js\nenableLiveReload({ strategy: 'react-hmr' })\n```\n\nExample - https://github.com/rllola/hmr-example-issue-2/blob/master/src/index.js\n\n### Source Maps\n\nIf you use `devtool: 'source-map'` (or its equivalent), source maps will be\nemitted to hide hot reloading code.\n\nSource maps slow down your project. Use `devtool: 'eval'` for best build\nperformance.\n\nHot reloading code is just one line in the beginning and one line in the end of\neach module so you might not need source maps at all.\n\n## React Native\n\nReact Native\n**[supports hot reloading natively](https://facebook.github.io/react-native/blog/2016/03/24/introducing-hot-reloading.html)**\nas of version 0.22.\n\nUsing React Hot Loader with React Native can cause unexpected issues (see #824) and is not recommended.\n\n### Code Splitting\n\nAs long most of modern react-component-loader\n([loadable-components](https://github.com/smooth-code/loadable-components/),\n[react-loadable](https://github.com/thejameskyle/react-loadable), and so on)\ndoes not, and should not support RHL, just mark export of the imported component as\n`hotExported`.\n\nExample using\n[loadable-components](https://github.com/smooth-code/loadable-components/):\n\n```js\n// AsyncHello.js\nimport loadable from 'loadable-components'\nconst AsyncHello = loadable(() => import('./Hello.js'))\n\n// Hello.js\nimport { hot } from 'react-hot-loader'\nconst Hello = () => 'Hello'\nexport default hot(module)(Hello) // <-- the only change to do\n```\n\n### Checking Element `type`s\n\nBecause React Hot Loader creates proxied versions of your components, comparing\nreference types of elements won't work:\n\n```js\nconst element = <Component />\nconsole.log(element.type === Component) // false\n```\n\nReact Hot Loader exposes a function `areComponentsEqual` to make it possible:\n\n```js\nimport { areComponentsEqual } from 'react-hot-loader'\nconst element = <Component />\nareComponentsEqual(element.type, Component) // true\n```\n\n### Webpack ExtractTextPlugin & CommonModulePlugin\n\nWebpack ExtractTextPlugin is not compatible with these two plugins. The solution is simple, disable them in development:\n\n```js\n// Example for ExtractTextPlugin\nnew ExtractTextPlugin({\n  filename: 'styles/[name].[contenthash].css',\n  disable: NODE_ENV !== 'production',\n})\n```\n\n## API\n\n### `hot(module, options)`\n\nMark a component as hot.\n\n```js\nimport { hot } from 'react-hot-loader'\n\nconst App = () => 'Hello World!'\n\nexport default hot(module)(App)\n```\n\n### `AppContainer`\n\nMark application as hot reloadable. Prefer using `hot` helper.\n\n```js\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport { AppContainer } from 'react-hot-loader'\nimport App from './containers/App'\n\nconst render = Component => {\n  ReactDOM.render(\n    <AppContainer>\n      <Component />\n    </AppContainer>,\n    document.getElementById('root'),\n  )\n}\n\nrender(App)\n\n// Webpack Hot Module Replacement API\nif (module.hot) {\n  module.hot.accept('./containers/App', () => {\n    // if you are using harmony modules ({modules:false})\n    render(App)\n    // in all other cases - re-require App manually\n    render(require('./containers/App'))\n  })\n}\n```\n\n### areComponentsEqual(Component1, Component2)\n\nTest if two components have the same type.\n\n```js\nimport { areComponentsEqual } from 'react-hot-loader'\nimport Component1 from './Component1'\nimport Component2 from './Component2'\n\nareComponentsEqual(Component1, Component2) // true or false\n```\n\n### setConfig(config)\n\nSet a new configuration for React Hot Loader.\n\nAvailable options are:\n\n* `logLevel`: specify log level, default to `\"error\"`, available values are: `['debug', 'log', 'warn', 'error']`\n\n```js\nimport { setConfig } from 'react-hot-loader'\n\nsetConfig({ logLevel: 'debug' })\n```\n\n## Migrating from v3\n\n### AppContainer vs hot\n\nPrior v4 the right way to setup React Hot Loader was to wrap your Application\nwith `AppContainer`, set setup module acceptance by yourself. This approach is\nstill valid but only for advanced use cases, prefer using `hot` helper.\n\n**React Hot Loader v3:**\n\n```js\n// App.js\nimport React from 'react'\n\nconst App = () => <div>Hello world!</div>\n\nexport default App\n```\n\n```js\n// main.js\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport { AppContainer } from 'react-hot-loader'\nimport App from './containers/App'\n\nconst render = Component => {\n  ReactDOM.render(\n    <AppContainer>\n      <Component />\n    </AppContainer>,\n    document.getElementById('root'),\n  )\n}\n\nrender(App)\n\n// Webpack Hot Module Replacement API\nif (module.hot) {\n  module.hot.accept('./containers/App', () => {\n    // if you are using harmony modules ({modules:false})\n    render(App)\n    // in all other cases - re-require App manually\n    render(require('./containers/App'))\n  })\n}\n```\n\n**React Hot Loader v4:**\n\n```js\n// App.js\nimport React from 'react'\nimport { hot } from 'react-hot-loader'\n\nconst App = () => <div>Hello world!</div>\n\nexport default hot(module)(App)\n```\n\n```js\n// main.js\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport App from './containers/App'\n\nReactDOM.render(<App />, document.getElementById('root'))\n```\n\n### No patch required\n\nCode is automatically patched, you can safely remove `react-hot-loader/patch`\nfrom your Webpack config.\n\n### Error reporter is gone\n\nReact supports error handling out of the box since v16 using `componentDidCatch`. You can create your own [Error Boundary](https://reactjs.org/docs/error-boundaries.html#introducing-error-boundaries) and install it after `hot` has been applied:\n\n```js\nimport React from 'react'\nimport { hot } from 'react-hot-loader'\nimport ErrorBoundary from './ErrorBoundary'\n\nconst App = () => (\n  <ErrorBoundary>\n    <div>Hello world!</div>\n  </ErrorBoundary>\n)\n\nexport default hot(module)(App)\n```\n\n## Known limitations and side effects\n\n### The original class got updated\n\nOn code replace you are replacing the old code by a new one. You should not use\nthe old code, as thus allow RHL to safely modify it. See\n[`react-stand-in`](https://github.com/gaearon/react-hot-loader/tree/next/packages/react-stand-in)\nfor more details.\n\n### New Components keep executing the old code\n\nThere is no way to hot-update constructor code, as result even new components\nwill be born as the first ones, and then grow into the last ones. See\n[`react-stand-in`](https://github.com/gaearon/react-hot-loader/tree/next/packages/react-stand-in)\nfor more details.\n\n## Troubleshooting\n\nIf it doesn't work, in 99% cases it's a configuration issue. A missing option, a\nwrong path or port. Webpack is very strict about configuration, and the best way\nto find out what's wrong is to compare your project to an already working setup,\ncheck out\n**[examples](https://github.com/gaearon/react-hot-loader/tree/next/examples)**,\nbit by bit.\n\nIf something doesn't work, in 99% cases it's an issue with your code - Component\ndoesn't got registered, due to HOC or Decorator around it, which making it\ninvisible to Babel plugin, or Webpack loader.\n\nWe're also gathering\n**[Troubleshooting Recipes](https://github.com/gaearon/react-hot-loader/blob/next/docs/Troubleshooting.md)**\nso send a PR if you have a lesson to share!\n\n### Switch into debug mode\n\nDebug mode adds additional warnings and can tells you why React Hot Loader is\nnot working properly in your application.\n\n```js\nimport { setConfig } from 'react-hot-loader'\nsetConfig({ logLevel: 'debug' })\n```\n\n## License\n\nMIT\n\n[build-badge]: https://img.shields.io/travis/gaearon/react-hot-loader.svg?style=flat-square\n[build]: https://travis-ci.org/gaearon/react-hot-loader\n[coverage-badge]: https://img.shields.io/codecov/c/github/gaearon/react-hot-loader.svg?style=flat-square\n[coverage]: https://codecov.io/github/gaearon/react-hot-loader\n[version-badge]: https://img.shields.io/npm/v/react-hot-loader.svg?style=flat-square\n[package]: https://www.npmjs.com/package/react-hot-loader\n[license-badge]: https://img.shields.io/npm/l/react-hot-loader.svg?style=flat-square\n[license]: https://github.com/gaearon/react-hot-loader/blob/next/LICENSE\n[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\n[prs]: http://makeapullrequest.com\n[chat]: https://gitter.im/gaearon/react-hot-loader\n[chat-badge]: https://img.shields.io/gitter/room/gaearon/react-hot-loader.svg?style=flat-square\n[github-watch-badge]: https://img.shields.io/github/watchers/gaearon/react-hot-loader.svg?style=social\n[github-watch]: https://github.com/gaearon/react-hot-loader/watchers\n[github-star-badge]: https://img.shields.io/github/stars/gaearon/react-hot-loader.svg?style=social\n[github-star]: https://github.com/gaearon/react-hot-loader/stargazers\n","engines":{"node":">= 6"},"gitHead":"f7ca913946d4cbc471cf9bbed900416a992cfd6d","license":"MIT","scripts":{"ci":"scripts/ci.sh","lint":"eslint .","test":"yarn test:es2015 && yarn test:modern","build":"rollup -c","format":"prettier --write \"**/*.{js,md,ts,json}\" *.{js,md,ts,json}","release":"standard-version -p && conventional-github-releaser -p angular","prebuild":"rm -rf dist","precommit":"lint-staged","test:es2015":"cross-env BABEL_TARGET=es2015 jest --no-cache","test:modern":"cross-env BABEL_TARGET=modern jest --no-cache","prepublishOnly":"yarn build"},"_npmUser":{"name":"neoziro","email":"berge.greg@gmail.com"},"homepage":"https://github.com/gaearon/react-hot-loader","keywords":["react","javascript","webpack","hmr","livereload","live","edit","hot","loader","reload"],"repository":{"url":"git+https://github.com/gaearon/react-hot-loader.git","type":"git"},"_npmVersion":"5.6.0","description":"Tweak React components in real time.","directories":{},"lint-staged":{"*.{js,md,ts,json}":["prettier --write","git add"]},"maintainers":[{"name":"calesce","email":"newman.cale@gmail.com"},{"name":"gaearon","email":"dan.abramov@gmail.com"},{"name":"kashey","email":"thekashey@gmail.com"},{"name":"montogeek","email":"montogeek@gmail.com"},{"name":"neoziro","email":"berge.greg@gmail.com"},{"name":"wkwiatek","email":"wojtek.kwiatek@gmail.com"}],"_nodeVersion":"9.5.0","dependencies":{"global":"^4.3.0","prop-types":"^15.6.0","shallowequal":"^1.0.2","fast-levenshtein":"^2.0.6","hoist-non-react-statics":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^22.3.0","husky":"^0.14.3","react":"^16.2.0","enzyme":"^3.3.0","eslint":"^4.18.0","rimraf":"^2.5.2","rollup":"^0.56.1","codecov":"^3.0.0","prettier":"^1.10.2","babel-cli":"^6.7.5","cross-env":"^5.1.3","react-dom":"^16.2.0","recompose":"^0.26.0","babel-core":"^6.7.6","babel-jest":"^22.2.2","lint-staged":"^6.1.1","react-mount":"^0.1.3","babel-eslint":"^8.2.1","babel-preset-env":"^1.6.0","standard-version":"^4.3.0","babel-preset-react":"^6.5.0","create-react-class":"^15.6.3","rollup-plugin-json":"^2.3.0","eslint-plugin-react":"^7.6.1","react-test-renderer":"16","rollup-plugin-babel":"^3.0.3","eslint-config-airbnb":"^16.0.0","eslint-plugin-import":"^2.7.0","rollup-plugin-uglify":"^3.0.0","rollup-plugin-replace":"^2.0.0","eslint-config-prettier":"^2.6.0","eslint-plugin-jsx-a11y":"^6.0.3","rollup-plugin-commonjs":"^8.3.0","enzyme-adapter-react-15":"^1.0.5","enzyme-adapter-react-16":"^1.1.1","rollup-plugin-node-resolve":"^3.0.3","conventional-github-releaser":"^2.0.0","babel-plugin-external-helpers":"^6.22.0","babel-plugin-dynamic-import-node":"^1.2.0","babel-plugin-transform-class-properties":"^6.24.1","babel-plugin-transform-object-rest-spread":"^6.26.0"},"peerDependencies":{"react":"^15.0.0 || ^16.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-hot-loader_4.0.0-beta.23_1518990295147_0.3124466269333821","host":"s3://npm-registry-packages"},"_id":"react-hot-loader@4.0.0-beta.23","version":"4.0.0-beta.23"}