Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-hot-loader

gaearon2mMIT4.13.1TypeScript support: included

Tweak React components in real time.

react, javascript, webpack, hmr, livereload, live, edit, hot, loader, reload

readme

React Hot Loader

Build Status version Code Coverage MIT License

PRs Welcome Chat Backers on Open Collective Sponsors on Open Collective

Watch on GitHub Star on GitHub

Tweak React components in real time ⚛️⚡️

Watch Dan Abramov's talk on Hot Reloading with Time Travel.

Moving towards next step

React-Hot-Loader has been your friendly neighbour, living outside of React. But it has been limiting its powers and causing not the greatest experience. It's time to make a next step.

React-Hot-Loader is expected to be replaced by React Fast Refresh. Please remove React-Hot-Loader if Fast Refresh is currently supported on your environment.

Install

npm install react-hot-loader

Note: You can safely install react-hot-loader as a regular dependency instead of a dev dependency as it automatically ensures it is not executed in production and the footprint is minimal.

Getting started

  1. Add react-hot-loader/babel to your .babelrc:
// .babelrc
{
  "plugins": ["react-hot-loader/babel"]
}
  1. Mark your root component as hot-exported:
// App.js
import { hot } from 'react-hot-loader/root';
const App = () => <div>Hello World!</div>;
export default hot(App);
  1. Make sure react-hot-loader is required before react and react-dom:

  2. or import 'react-hot-loader' in your main file (before React)

  3. or prepend your webpack entry point with react-hot-loader/patch, for example:

    // webpack.config.js
    module.exports = {
      entry: ['react-hot-loader/patch', './src'],
      // ...
    };
  4. If you need hooks support, use @hot-loader/react-dom

Hook support

Hooks would be auto updated on HMR if they should be. There is only one condition for it - a non zero dependencies list.

❄️ useState(initialState); // will never updated (preserve state)
❄️ useEffect(effect); // no need to update, updated on every render
❄️ useEffect(effect, []); // "on mount" hook. "Not changing the past"
🔥 useEffect(effect, [anyDep]); // would be updated

🔥 useEffect(effect, ["hot"]); // the simplest way to make hook reloadable

Plus

  • any hook would be reloaded on a function body change. Enabled by default, controlled by reloadHooksOnBodyChange option.
  • you may configure RHL to reload any hook by setting reloadLifeCycleHooks option to true.

To disable hooks reloading - set configuration option:

import { setConfig } from 'react-hot-loader';

setConfig({
  reloadHooks: false,
});

With this option set all useEffects, useCallbacks and useMemo would be updated on Hot Module Replacement.

Hooks reset

Hooks would be reset if their order changes. Adding, removing or moving around would cause a local tree remount.

Babel plugin is required for this operation. Without it changing hook order would throw an error which would be propagated till the nearest class-based component.

@hot-loader/react-dom

@hot-loader/react-dom replaces the "react-dom" package of the same version, but with additional patches to support hot reloading.

There are 2 ways to install it:

  • Use yarn name resolution, so @hot-loader/react-dom would be installed instead of react-dom
yarn add react-dom@npm:@hot-loader/react-dom
yarn add @hot-loader/react-dom
// webpack.config.js
module.exports = {
  // ...
  resolve: {
    alias: {
      'react-dom': '@hot-loader/react-dom',
    },
  },
};

Old API

Note: There is also an old version of hot, used prior to version 4.5.4. Please use the new one, as it is much more resilient to js errors that you may make during development.

Meanwhile, not all the bundlers are compatible with new /root API, for example parcel is not.

React-Hot-Load will throw an error, asking you to use the old API, if such incompatibility would be detected. It is almost the same, but you have to pass module inside hot.

import { hot } from 'react-hot-loader';
const App = () => <div>Hello World!</div>;
export default hot(module)(App);
  1. Run webpack with Hot Module Replacement:
webpack-dev-server --hot

What about production?

The webpack patch, hot, Babel plugin, @hot-loader/react-dom etc. are all safe to use in production; they leave a minimal footprint, so there is no need to complicate your configuration based on the environment. Using the Babel plugin in production is even recommended because it switches to cleanup mode.

Just ensure that the production mode has been properly set, both as an environment variable and in your bundler. E.g. with webpack you would build your code by running something like:

NODE_ENV=production webpack --mode production

NODE_ENV=production is needed for the Babel plugin, while --mode production uses webpack.DefinePlugin to set process.env.NODE_ENV inside the compiled code itself, which is used by hot and @hot-loader/react-dom.

Make sure to watch your bundle size when implementing react-hot-loader to ensure that you did it correctly.

Limitations

  • (that's the goal) React-Hot-Loader would not change the past, only update the present - no lifecycle event would be called on component update. As a result, any code changes made to componentWillUnmount or componentDidMount would be ignored for already created components.
  • (that's the goal) React-Hot-Loader would not update any object, including component state.
  • (1%) React-Hot-Loader may not apply some changes made to a component's constructor. Unless an existing component is recreated, RHL would typically inject new data into that component, but there is no way to detect the actual change or the way it was applied, especially if the change was made to a function. This is because of the way React-Hot-Loader works - it knows what class functions are, not how they were created. See #1001 for details.

Recipes

Migrating from create-react-app

  1. Run npm run eject
  2. Install React Hot Loader (npm install --save-dev react-hot-loader)
  3. In config/webpack.config.dev.js, add 'react-hot-loader/babel' to Babel loader configuration. The loader should now look like:
  {
    test: /\.(js|jsx)$/,
    include: paths.appSrc,
    loader: require.resolve('babel-loader'),
    options: {
      // This is a feature of `babel-loader` for webpack (not Babel itself).
      // It enables caching results in ./node_modules/.cache/babel-loader/
      // directory for faster rebuilds.
      cacheDirectory: true,
      plugins: ['react-hot-loader/babel'],
    },
  }
  1. Mark your App (src/App.js) as hot-exported:
// ./containers/App.js
import React from 'react';
import { hot } from 'react-hot-loader';

const App = () => <div>Hello World!</div>;

export default hot(module)(App);

Migrating from create-react-app without ejecting

Users report, that it is possible to use react-app-rewire-hot-loader to setup React-hot-loader without ejecting.

TypeScript

As of version 4, React Hot Loader requires you to pass your code through Babel to transform it so that it can be hot-reloaded. This can be a pain point for TypeScript users, who usually do not need to integrate Babel as part of their build process.

Fortunately, it's simpler than it may seem! Babel will happily parse TypeScript syntax and can act as an alternative to the TypeScript compiler, so you can safely replace ts-loader or awesome-typescript-loader in your Webpack configuration with babel-loader. Babel won't typecheck your code, but you can use fork-ts-checker-webpack-plugin (and/or invoke tsc --noEmit) as part of your build process instead.

A sample configuration:

{
  // ...you'll probably need to configure the usual Webpack fields like "mode" and "entry", too.
  resolve: { extensions: [".ts", ".tsx", ".js", ".jsx"] },
  module: {
    rules: [
      {
        test: /\.(j|t)sx?$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
          options: {
            cacheDirectory: true,
            babelrc: false,
            presets: [
              [
                "@babel/preset-env",
                { targets: { browsers: "last 2 versions" } } // or whatever your project requires
              ],
              "@babel/preset-typescript",
              "@babel/preset-react"
            ],
            plugins: [
              // plugin-proposal-decorators is only needed if you're using experimental decorators in TypeScript
              ["@babel/plugin-proposal-decorators", { legacy: true }],
              ["@babel/plugin-proposal-class-properties", { loose: true }],
              "react-hot-loader/babel"
            ]
          }
        }
      }
    ]
  },
  plugins: [
    new ForkTsCheckerWebpackPlugin()
  ]
};

For a full example configuration of TypeScript with React Hot Loader and newest beta version of Babel, check here.

As an alternative to this approach, it's possible to chain Webpack loaders so that your code passes through Babel and then TypeScript (or TypeScript and then Babel), but this approach is not recommended as it is more complex and may be significantly less performant. Read more discussion here.

Parcel

Parcel supports Hot Module Reloading out of the box, just follow step 1 and 2 of Getting Started.

We also have a full example running Parcel + React Hot Loader.

Electron

You need something to mark your modules as hot in order to use React Hot Loader.

One way of doing this with Electron is to simply use webpack like any web-based project might do and the general guide above describes. See also this example Electron app.

A webpack-less way of doing it to use electron-compile (which is also used by electron-forge) - see this example. While it requires less configuration, something to keep in mind is that electron-compile's HMR will always reload all modules, regardless of what was actually edited.

Source Maps

If you use devtool: 'source-map' (or its equivalent), source maps will be emitted to hide hot reloading code.

Source maps slow down your project. Use devtool: 'eval' for best build performance.

Hot reloading code is just one line in the beginning and one line at the end of each module so you might not need source maps at all.

Linking

If you are using npm link or yarn link for development purposes, there is a chance you will get error Module not found: Error: Cannot resolve module 'react-hot-loader' or the linked package is not hot reloaded.

There are 2 ways to fix Module not found:

  • Use include in loader configuration to only opt-in your app's files to processing.
  • Alternatively if you are using webpack, override the module resolution in your config:
{
  resolve: {
    alias: {
      'react-hot-loader': path.resolve(path.join(__dirname, './node_modules/react-hot-loader')),
    }
  }
}

And to make your linked package to be hot reloaded, it will need to use the patched version of react and react-dom, if you're using webpack, add this options to the alias config

{
  resolve: {
    alias: {
      'react-hot-loader': path.resolve(path.join(__dirname, './node_modules/react-hot-loader')),
      // add these 2 lines below so linked package will reference the patched version of `react` and `react-dom`
      'react': path.resolve(path.join(__dirname, './node_modules/react')),
      'react-dom': path.resolve(path.join(__dirname, './node_modules/react-dom')),
      // or point react-dom above to './node_modules/@hot-loader/react-dom' if you are using it
    }
  }
}

Preact

React-hot-loader should work out of the box with preact-compat, but, in case of pure preact, you will need to configure it:

  • create configuration file (setupHotLoader.js)
import reactHotLoader from 'react-hot-loader';
import preact from 'preact';

reactHotLoader.preact(preact);
  • dont forget to import it

Preact limitations

  • HOCs and Decorators as not supported yet. For Preact React-Hot-Loader v4 behave as v3.

React Native

React Native supports hot reloading natively as of version 0.22.

Using React Hot Loader with React Native can cause unexpected issues (see #824) and is not recommended.

Webpack plugin

We recommend using the babel plugin, but there are some situations where you are unable to. If so, try the webpack plugin / webpack-loader (as seen in v3).

Remember - the webpack plugin is not compatible with class-based components. The babel plugin will inject special methods to every class, to make class members (like onClick) hot-updatable, while the webpack plugin would leave classes as is, without any instrumentation.

class MyComponent extends React.Component {
  onClick = () => this.setState(); // COULD NOT UPDATE
  variable = 1; // this is ok
  render() {} // this is ok
}

But webpack-loader could help with TypeScript or spreading "cold API" to all node_modules.

It is possible to enable this loader for all the files, but if you use babel plugin, you need to enable this loader for react-dom only. Place it after babel-loader, if babel-loader is present.

// webpack.config.js
module.exports = {
  module: {
    rules: [
      // would only land a "hot-patch" to react-dom
      {
        test: /\.js$/,
        include: /node_modules\/react-dom/,
        use: ['react-hot-loader/webpack'],
      },
    ],
  },
};

Webpack plugin will also land a "hot" patch to react-dom, making React-Hot-Loader more compliant to the principles.

If you are not using babel plugin you might need to apply webpack-loader to all the files.

{
  test: /\.jsx?$/,
  include: /node_modules/,
  use: ['react-hot-loader/webpack']
},

Code Splitting

If you want to use Code Splitting + React Hot Loader, the simplest solution is to pick a library compatible with this one:

If you use a not-yet-friendly library, like react-async-component, or are having problems with hot reloading failing to reload code-split components, you can manually mark the components below the code-split boundaries.

// AsyncHello.js
import { asyncComponent } from 'react-async-component';

// asyncComponent could not `hot-reload` itself.
const AsyncHello = asyncComponent({
  resolve: () => import('./Hello'),
});

export default AsyncHello;

Note that Hello is the component at the root of this particular code-split chunk.

// Hello.js
import { hot } from 'react-hot-loader/root';

const Hello = () => 'Hello';

export default hot(Hello); // <-- module will reload itself

Wrapping this root component with hot() will ensure that it is hot reloaded correctly.

Out-of-bound warning

You may see the following warning when code-split components are updated:

React-Hot-Loader: some components were updated out-of-bound. Updating your app to reconcile the changes.

This is because the hot reloading of code-split components happens asynchronously. If you had an App.js that implemented the AsyncHello component above and you modified AsyncHello, it would be bundled and reloaded at the same time as App.js. However, the core hot reloading logic is synchronous, meaning that it's possible for the hot reload to run before the updates to the split component have landed.

In this case, RHL uses a special tail update detection logic, where it notes that an an update to a split component has happened after the core hot reloading logic has already finished, and it triggers another update cycle to ensure that all changes are applied.

The warning is informational - it is a notice that this tail update logic is triggered, and does not indicate a problem in the configuration or useage of react-hot-loader.

If the tail update detection is not something you want or need, you can disable this behavior by setting setConfig({ trackTailUpdates:false }).

Checking Element types

Because React Hot Loader creates proxied versions of your components, comparing reference types of elements won't work:

const element = <Component />;
console.log(element.type === Component); // false

React Hot Loader exposes a function areComponentsEqual to make it possible:

import { areComponentsEqual } from 'react-hot-loader';
const element = <Component />;
areComponentsEqual(element.type, Component); // true

Another way - compare "rendered" element type

const element = <Component />;
console.log(element.type === <Component />.type); // true

// better - precache rendered type
const element = <Component />;
const ComponentType = <Component />.type;
console.log(element.type === ComponentType); // true

But you might have to provide all required props. See original issue. This is most reliable way to compare components, but it will not work with required props.

Another way - compare Component name.

Not all components have a name. In production displayName could not exists.

const element = <Component />;
console.log(element.displayName === 'Component'); // true

This is something we did not solve yet. Cold API could help keep original types.

Webpack ExtractTextPlugin

webpack ExtractTextPlugin is not compatible with React Hot Loader. Please disable it in development:

new ExtractTextPlugin({
  filename: 'styles/[name].[contenthash].css',
  disable: NODE_ENV !== 'production',
});

Disabling a type change (❄️)

It is possible to disable React-Hot-Loader for a specific component, especially to enable common way to type comparison. See #991 for the idea behind ⛄️, and #304 about "type comparison" problem.

import { cold } from 'react-hot-loader';

cold(SomeComponent) // this component will ignored by React-Hot-Loader
<SomeComponent />.type === SomeComponent // true

If you will update cold component React-Hot-Loader will complain (on error level), and then React will cold-replace Component with a internal state lose.

Reach-Hot-Loader: cold element got updated

Disabling a type change for all node_modules

You may cold all components from node_modules. This will not work for HOC(like Redux) or dynamically created Components, but might help in most of situations, when type changes are not welcomed, and modules are not expected to change.

import { setConfig, cold } from 'react-hot-loader';
setConfig({
  onComponentRegister: (type, name, file) => file.indexOf('node_modules') > 0 && cold(type),

  // some components are not visible as top level variables,
  // thus its not known where they were created
  onComponentCreate: (type, name) => name.indexOf('styled') > 0 && cold(type),
});

! To be able to "cold" components from 'node_modules' you have to apply babel to node_modules, while this folder is usually excluded. You may add one more babel-loader, with only one React-Hot-Loader plugin inside to solve this. Consider using webpack-loader for this.

React-Hooks

React hooks are not really supported by React-Hot-Loader. Mostly due to our internal processes of re-rendering React Tree, which is required to reconcile an updated application before React will try to rerender it, and fail to do that, obviously.

  • hooks should work for versions 4.6.0 and above (pureSFC is enabled by default).
  • hooks will produce errors on every hot-update without patches to react-dom.
  • hooks may loss the state without patches to react-dom.
  • hooks does not support adding new hooks on the fly
  • change in hooks for a mounted components will cause a runtime exception, and a retry button (at the nearest class component) will be shown. Pressing a retry button will basically remount tree branch.

To mitigate any hook-related issues (and disable their hot-reloadability) - cold them.

  • cold components using hooks.
import { setConfig, cold } from 'react-hot-loader';
setConfig({
  onComponentCreate: (type, name) =>
    (String(type).indexOf('useState') > 0 || String(type).indexOf('useEffect') > 0) && cold(type),
});

API

hot(Component, options)

Mark a component as hot.

Babel plugin

Right now babel plugin has only one option, enabled by default.

  • safetyNet - will help you properly setup ReactHotLoader.

You may disable it to get more control on the module execution order.

//.babelrc
{
    "plugins": [
        [
            "react-hot-loader/babel",
            {
            "safetyNet": false
            }
        ]
    ]
}

Important

!! Use hot only for module exports, not for module imports. !!

import { hot } from 'react-hot-loader/root';

const App = () => 'Hello World!';

export default hot(App);

Keep in mind - by importing react-hot-loader/root you are setting up a boundary for update event propagation.

The higher(in module hierarchy) you have it - the more stuff would be updated on Hot Module Replacement.

To make RHL more reliable and safe, please place hot below (ie somewhere in imported modules):

  • react-dom
  • redux store creation
  • any data, you want to preserve between updates
  • big libraries

You may(but it's not required) place hot to the every route/page/feature/lazy chunk, thus make updates more scoped.

You don't need to wrap every component with hot, application works fine with a single one.

(old)hot(module, options)(Component, options)

Mark a component as hot. The "new" hot is just hidding the first part - hot(module), giving you only the second (App). The "new" hot is using old API.

import { hot } from 'react-hot-loader';

const App = () => 'Hello World!';

export default hot(module)(App);

AppContainer

Mark application as hot reloadable. (Prefer using hot helper, see below for migration details).

This low-level approach lets you make *hot *imports__, not exports.

import React from 'react';
import ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import App from './containers/App';

const render = Component => {
  ReactDOM.render(
    <AppContainer>
      <Component />
    </AppContainer>,
    document.getElementById('root'),
  );
};

render(App);

// webpack Hot Module Replacement API
if (module.hot) {
  // keep in mind - here you are configuring HMR to accept CHILDREN MODULE
  // while `hot` would configure HMR for the CURRENT module
  module.hot.accept('./containers/App', () => {
    // if you are using harmony modules ({modules:false})
    render(App);
    // in all other cases - re-require App manually
    render(require('./containers/App'));
  });
}

areComponentsEqual(Component1, Component2)

Test if two components have the same type.

import { areComponentsEqual } from 'react-hot-loader';
import Component1 from './Component1';
import Component2 from './Component2';

areComponentsEqual(Component1, Component2); // true or false

setConfig(config)

Set a new configuration for React Hot Loader.

Available options are:

  • logLevel: specify log level, default to "error", available values are: ['debug', 'log', 'warn', 'error']
  • pureSFC: enable Stateless Functional Component. If disabled they will be converted to React Components. Default value: false.
  • ignoreSFC: skip "patch" for SFC. "Hot loading" could still work, with webpack-patch present
  • pureRender: do not amend render method of any component.
  • for the rest see index.d.ts.
// rhlConfig.js
import { setConfig } from 'react-hot-loader';

setConfig({ logLevel: 'debug' });

It is important to set configuration before any other action will take a place

// index.js
import './rhlConfig' // <-- extract configuration to a separate file, and import it in the beggining
import React from 'react'
....

Migrating from v3

AppContainer vs hot

Prior v4 the right way to setup React Hot Loader was to wrap your Application with AppContainer, set setup module acceptance by yourself. This approach is still valid but only for advanced use cases, prefer using hot helper.

React Hot Loader v3:

// App.js
import React from 'react';

const App = () => <div>Hello world!</div>;

export default App;
// main.js
import React from 'react';
import ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import App from './containers/App';

const render = Component => {
  ReactDOM.render(
    <AppContainer>
      <Component />
    </AppContainer>,
    document.getElementById('root'),
  );
};

render(App);

// webpack Hot Module Replacement API
if (module.hot) {
  module.hot.accept('./containers/App', () => {
    // if you are using harmony modules ({modules:false})
    render(App);
    // in all other cases - re-require App manually
    render(require('./containers/App'));
  });
}

React Hot Loader v4:

// App.js
import React from 'react';
import { hot } from 'react-hot-loader';

const App = () => <div>Hello world!</div>;

export default hot(module)(App);
// main.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './containers/App';

ReactDOM.render(<App />, document.getElementById('root'));

Patch is optional

Since 4.0 till 4.8

Code is automatically patched, you can safely remove react-hot-loader/patch from your webpack config, if react-hot-loader is required before React in any other way.

Error Boundary is inside every component

Since 4.5.4

On Hot Module Update we will inject componentDidCatch and a special render to every Class-based component you have, making Error Boundaries more local.

After update we will remove all sugar, keeping only Boundaries you've created.

You can provide your own errorReporter, via setConfig({errorReporter}) or opt-out from root ErrorBoundaries setting errorBoundary={false} prop on AppContainer or hot. However - this option affects only SFC behavior, and any ClassComponent would boundary itself.

import { setConfig } from 'react-hot-loader';
import ErrorBoundary from './ErrorBoundary';

// ErrorBoundary will be given error and errorInfo prop.
setConfig({ errorReporter: ErrorBoundary });

If errorReporter is not set - full screen error overlay would be shown.

Setting global Error Reporter

Global Error Reporter would, created a fixed overlay on top the page, would be used to display errors, not handled by errorReporter, and any HMR error.

You may change, or disable this global error overlay

// to disable
setConfig({ ErrorOverlay: () => null });

// to change
setConfig({ ErrorOverlay: MyErrorOverlay });

The UX of existing overlay is a subject to change, and we are open to any proposals.

Known limitations and side effects

Note about hot

hot accepts only React Component (Stateful or Stateless), resulting the HotExported variant of it. The hot function will setup current module to self-accept itself on reload, and will ignore all the changes, made for non-React components. You may mark as many modules as you want. But HotExportedComponent should be the only used export of a hot-module.

Note: Please note how often we have used exported keyword. hot is for exports.

Note: Does nothing in production mode, just passes App through.

New Components keep executing the old code

There is no way to hot-update constructor code, as result even new components will be born as the first ones, and then grow into the last ones. As of today, this issue cannot be solved.

Troubleshooting

If it doesn't work, in 99% of cases it's a configuration issue. A missing option, a wrong path or port. webpack is very strict about configuration, and the best way to find out what's wrong is to compare your project to an already working setup, check out examples, bit by bit.

If something doesn't work, in 99% of cases it's an issue with your code. The Component didn't get registered, due to HOC or Decorator around it, which is making it invisible to the Babel plugin or webpack loader.

We're also gathering Troubleshooting Recipes so send a PR if you have a lesson to share!

Switch into debug mode

Debug mode adds additional warnings and can tells you why React Hot Loader is not working properly in your application.

import { setConfig } from 'react-hot-loader';
setConfig({ logLevel: 'debug' });

Contributors

This project exists thanks to all the people who contribute. Contribute. contributors

Backers

Thank you to all our backers! 🙏 Become a backer backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. Become a sponsor

License

MIT

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

4.13.0 (2020-09-22)

Bug Fixes

Features

4.12.21 (2020-04-30)

Bug Fixes

  • add peerDependenciesMeta in package.json (#1433)

4.12.20 (2020-03-14)

Bug Fixes

4.12.19 (2020-01-22)

Bug Fixes

4.12.18 (2019-11-16)

Bug Fixes

  • (regression) hook order change is causing React error, fixes #1393 (6707b4b)
  • production babel plugin might perform eager replacement, fixes #1388 (b94adb3)

4.12.17 (2019-11-12)

Bug Fixes

  • move @types/react from to peer dependencies, fixes #1391 (5ab2cab)

4.12.16 (2019-11-06)

Bug Fixes

  • dont write to elementType if it is not defined, fixes #1357 (1072303)
  • explain why RHL could not be activated, fixes #1362 (9561d66)
  • more @types/react to dependencies, fixes #1359 (af42c1a)
  • use logger.warn instead of console to report tail update, fixes #1386 (fbc890a)

4.12.15 (2019-10-08)

Bug Fixes

4.12.14 (2019-09-23)

Bug Fixes

  • autodetect underupdated state and trigger an automatic update, fixes #1342 (33c54f5)
  • resolve all components to their last versions, #1342 (62bc67e)

4.12.13 (2019-09-12)

Bug Fixes

  • error overlay should not be injected into the first instance, fixes #1337 (c019663)
  • return null for null types, fixes #1324 (08d7ed1)
  • run hot in batched mode, fixes #1332 (e801daf)

4.12.12 (2019-08-27)

Bug Fixes

  • error overlay could fail by itself (da50985)
  • resolve undefined types to undefined, fixes #1324 (73eeb4e)
  • speedup levenshtein comparison, fixes #1087 (b81dcb0)

4.12.11 (2019-08-12)

Features

  • react 16.9 support, 1320 by @Bnaya

Bug Fixes

  • add noRegister option to webpack, #1315 (e562375)
  • remove circular deps from hot-loader (2cb544d)

4.12.10 (2019-07-27)

Bug Fixes

  • append react-hot-dom patch note to the ProxyFacade, fixes #1311 (81bbb6a)
  • use void IIFE for webpack plugin, fixes #1309 (6089822)

4.12.9 (2019-07-23)

Bug Fixes

  • forcely update Context Provider, fixes #1207 (897a68d)
  • updating shallowequal dependency (9269580)

4.12.8 (2019-07-18)

Bug Fixes

  • script error on IE11 due to lack of Object.entries (6672b26)

4.12.7 (2019-07-16)

Bug Fixes

  • false negative comparisons with react-hot-dom enabled, fixes #1299 (a1c5c31)
  • reload hooks when hook body changes (4795456)

4.12.6 (2019-07-10)

Bug Fixes

  • do not update hooks while updating hooks, fixes #1294 (afa8ed4)

4.12.5 (2019-07-07)

Bug Fixes

4.12.4 (2019-07-06)

Bug Fixes

4.12.3 (2019-07-04)

Bug Fixes

  • babel plugin should use only extrernals hooks, fixes #1285 (c435eaa)
  • make type comparison stronger (1b9f2da)
  • prevent different typeof of components to be merged (357249c)
  • regression of registered type comparison, fixes #1284 (49851be)

4.12.2 (2019-07-03)

Bug Fixes

  • [babel][prod] separate default and root 'hot' detection, fixes #1283 (c6d29c9)

4.12.1 (2019-07-03)

Bug Fixes

4.12.0 (2019-06-30)

Features

  • disable hot replacement render if react-dom is patched, see #1274 (b93eb1d)

4.11.2 (2019-06-30)

Bug Fixes

  • babel-plugin is not compatible with commonjs module output if babel 7 is used #1268.

4.11.1 (2019-06-15)

Bug Fixes

  • hot render of forward props component (4ba7530)
  • regression in hidden components reconcilation (3f8efc4)
  • update react-fresh babel plugin (2fafd44)

4.11.0 (2019-06-10)

Bug Fixes

  • source map consumer could be synchronous (05a6c8e)

Features

  • backport React.Fresh to handle hooks order change (e5c4bb4)

4.10.0 (2019-06-02)

Features

4.9.0 (2019-06-02)

Bug Fixes

  • false positive hot merge for forwardRef and Memo components, fixes #1257 (dbf1047)
  • improve hot api for production mode - error reporting and babel plugin (6b29911)

Features

4.8.8 (2019-05-23)

Bug Fixes

4.8.7 (2019-05-20)

Bug Fixes

4.8.6 (2019-05-18)

Bug Fixes

4.8.5 (2019-05-16)

Bug Fixes

4.8.4 (2019-04-15)

Bug Fixes

  • document the importance of import order, fixes #1209 (5f50ee4)
  • dont skip first update or plain components (432e0f8)
  • remove Object.assign, fixes #1226 (c5af009)

4.8.3 (2019-04-05)

Bug Fixes

  • Allow refs on lazy components (798e37f)
  • invariant violation react 15 (1351f2d)

4.8.1 (2019-03-29)

Bug Fixes

4.8.0 (2019-03-07)

Features

4.7.2 (2019-03-04)

Bug Fixes

  • safer reads from context consumer (7942d26)
  • suppress error message on a server side, fixes #1188 (b12b430)

4.7.1 (2019-02-20)

Bug Fixes

  • destructed Context.Provider breaking registrations. fixes #1184 (8240111)
  • do not poison memoized props (9f6ab6e)
  • rethrow an error is hot comparison is not open (8befa5a)

4.7.0 (2019-02-18)

Bug Fixes

  • complain if hot patches not present, fixes #1173 (efc3d6b)
  • deactivate RHL in dev mode if eval not allowed (f995b0d)
  • disable ErrorBoundaries for a first run, fixes #1172 (2a834c2)
  • Support Context.Provider reload and React.memo, fixes #1169 (09e48eb)

Features

  • activate pureRender by default (4e971b5)
  • implement flexible hot injections (b7e8f5e)
  • make errors retryable to mitigate hooks update (9967fde)

4.6.5 (2019-01-31)

Bug Fixes

  • babel plugin produces a broken code (6f8573f)

4.6.4 (2019-01-31)

Bug Fixes

  • do not shadow component name (4b02767)
  • do not supress HMR errors (be79d2f)
  • fix wrong react-dom name resolution installation (6f829a0)
  • opt-out for module safety net, fixes #1102, #1159 (93d0b1f)
  • remove platform checks from production bundle, fixes #1162 (24d0448)
  • update fiber cached type, fixes #1139 (35984ff)

4.6.3 (2018-12-19)

Bug Fixes

  • context information is not always properly emulated in hot-render, fixes #1094 (100fc9c)
  • RHL could update non-relative components (5d4f226)
  • update memo updater and comparator. fix #1135 (826a57c)

4.6.2 (2018-12-18)

Bug Fixes

  • allow multiple 'hot' in one file, registering only the first one (68c2a0a)
  • error overlay initialization prior body, fixes #1127 (9177aba)

4.6.1 (2018-12-17)

Bug Fixes

  • display hmr errors as hmr errors, #1131 (615790f)
  • error overlay is not server side friendly, #1126 (40e3ff2)
  • hmr error detection is flaky (9d3a2c0)
  • secure wrapped/uwrapped comparison (a62bacd)
  • webpack plugin outputs es2015 code (8a66401)

4.6.0 (2018-12-13)

Features

4.5.3 (2018-12-07)

Bug Fixes

  • enable class equality, but disable class merge, when not hot (8d214b3)
  • react-dom hot-replacement is too active (8827a40)

4.5.2 (2018-12-06)

Bug Fixes

  • forwardRef to be remounted every frame. React-router to merge components (3b11866)
  • React-router to merge components (f45fee0)
  • remove early reject, #1115 (0a28144)

4.5.1 (2018-11-21)

Bug Fixes

  • add lodash.merge as dep (1de55d6)

4.5.0 (2018-11-20)

Bug Fixes

Features

  • webpack patch/inject mode (42d637b)

4.4.0-1 (2018-11-01)

Bug Fixes

  • forwardRef reconciliation #1100

4.4.0 (2018-11-01)

Features

  • React 16.5 and React 16.6 support. forwardRef, memo, lazy #1084
  • Webpack loader #1098
  • mark RHL sideEffect-free in production mode #1096
  • babel plugin will remove hot in production #1091

Bug Fixes

  • babel plugin will remove calls to hot in production mode to remove side-effect on webpack #1081
  • class methods, deleted on update, will be deleted from proxy #1091

4.3.11 (2018-09-20)

Bug Fixes

  • hot fixing ES5 literals in index.js (80f6b63)

4.3.10 (2018-09-20)

Bug Fixes

  • IE10/CSP compatibility. #1073

4.3.7 (2018-09-13)

Bug Fixes

4.3.6 (2018-09-04)

Bug Fixes

  • don't inadvertendly call getters (322e746)

4.3.5 (2018-08-23)

Bug Fixes

  • dont hot-swap registered components, #1050 (cf165a6)
  • use the same conditions for index and patch (f67d5b9)

4.3.4 (2018-07-25)

Bug Fixes

  • element could be double-proxied (#1033)
  • Components, not directly inherited from React.Components, like StyledComponents, are not working (#1031)

4.3.3 (2018-06-15)

Bug Fixes

4.3.2 (2018-06-13)

Bug Fixes

  • Add cold API to TypeScript definitions

4.3.1 (2018-06-09)

Bug Fixes

  • Preact could pass arguments to the render, fix #1013 (605da10)
  • Support _this10 and over (bb47ca4)
  • Handle lazy indeterminate static properties(Relay) #1014

4.3.0 (2018-06-05)

Bug Fixes

  • Context Provider could crash due update, #944 (b0e2b5b)
  • RHL babel plugin will ignore react and react-hot-loader, fixes #900 (e90a25c)
  • RHL should add new class methods (111d56e)
  • Multiple problems with methods update. Revert behavior back to v4.1.2 #1001

Features

4.2.0 (2018-05-16)

Changes

  • Stateless Components will be converted to React.Component ones (as they were prior 4.1.0) #977

Features

  • Basic support for React 16 Context #979

Bug fixes

  • pure components wont update #959, #944
  • better babel compliance ("this5"), #969
  • sideeffect-less updates #970
  • render as a class property #924
  • issues around reactLifecyclesCompat.polyfill #951
  • more examples and test cases
  • multiple reconsilation related bug fixes

4.1.3 (2018-05-08)

Bug Fixes

4.1.2 (2018-04-24)

Bug Fixes

4.1.1 (2018-04-24)

Bug Fixes

4.1.0 (2018-04-18)

Features

  • 🚀 React 16.3 support (#918)
  • 🧙🏻‍♂️ StatelessFunctionComponents are not wrapped by Stateful components anymore (#873)
  • 🧠Improved TypeScript support (no more than documentation) (#884)

Bug Fixes

  • support babel temporal _this3 (#928)

4.0.1 (2018-04-01)

Bug Fixes

Docs

4.0.0 (2018-02-27)

Bug Fixes

4.0.0-rc.0 (2018-02-19)

4.0.0-beta.23 (2018-02-18)

Bug Fixes

4.0.0-beta.22 (2018-02-10)

Bug Fixes

Features

4.0.0-beta.21 (2018-02-05)

Bug Fixes

4.0.0-beta.20 (2018-02-04)

4.0.0-beta.19 (2018-02-03)

Bug Fixes

4.0.0-beta.18 (2018-01-25)

Bug Fixes

4.0.0-beta.17 (2018-01-22)

Features

Bug Fixes

  • warn about errors #814
  • handle wrong module #813

4.0.0-beta.16 (2018-01-21)

  • react-hot-loader: Hard code consts from stand-in #807)
  • react-hot-loader: Support React 16 Fragments #799)
  • react-hot-loader: Suppress some warnings #804)
  • react-hot-loader: Better Electron support #794)

  • react-stand-in: Fix IE11 regression (again)

4.0.0-beta.15 (2018-01-16)

  • react-deep-force-update: remove from the project
  • react-stand-in: fix MobX (Cannot assign to read only property 'render', #796)

4.0.0-beta.14 (2018-01-14)

  • react-hot-loader: support IE11 (#772)
  • react-stand-in: support Relay Classis/Modern(#775)

4.0.0-beta.13 (2018-01-09)

Features

  • react-hot-loader: detect wrong usage of hot (#766) (b9738c7), closes #765

4.0.0-beta.12 (2018-01-02)

Bug Fixes

  • target ES5 for production code (b1d6d05), closes #758

4.0.0-beta.11 (2017-12-30)

Bug Fixes

  • build: fix builded files (f4aa275)

4.0.0-beta.10 (2017-12-30)

Bug Fixes

4.0.0-beta.9 (2017-12-30)

Bug Fixes

  • react-hot-loader: require react-hot-loader/patch in each file (3038538), closes #750

4.0.0-beta.8 (2017-12-29)

Bug Fixes

  • react-hot-loader: fix missing export (239ca5d)

4.0.0-beta.7 (2017-12-29)

Bug Fixes

  • handle async loading of patch (#739) (af8bd4b)
  • react-hot-loader: fix componentWillUpdate (95a9e79)
  • use safe defineProperty (f901192)

Features

  • replace warnings by configure({ debug: true }) (4f079c6)

4.0.0-beta.6 (2017-12-27)

Same as 4.0.0-beta.5, fix build problem.

4.0.0-beta.5 (2017-12-27)

Bug Fixes

  • improve decorators support (autobind) (56883c9)
  • support nested children (#735) (5c81655)

Manual changelog

4.0.0-beta.4

  • Handle terminal node in stack (#728)

4.0.0-beta.3

  • Use setTimeout to tick (#726)

4.0.0-beta.2

  • Bunch of fixes (#725)

4.0.0-beta.1

  • Remove webpack plugin (#707)
  • Replace react-proxy by react-stand-in (#707)
  • Replace react-deep-force-update by reconciler (#703)
  • Add hot HOC (#707)
  • Add areComponentsEqual (#304)
  • warnings flag now controls reconciler, not dev patch.

3.1.1

  • Revert fix arrow function that uses props in constructor (#670)
  • Remove babel-template dependency (#671)

3.1.0

  • Add an option to disable warnings (#669)
  • Fix arrow function that uses props in constructor (#670)

3.0.0

  • Add React 16 support (#629, #658)
  • Remove RedBox as default error catcher (#494)

3.0.0-beta.6

  • Use production versions of patch and AppContainer if no module.hot available, so it doesn't break people using NODE_ENV=test. (#398)
  • Opt out of transforming static class properties. (#381)

3.0.0-beta.5

  • Makes the class properties portion of the Babel plugin work with async functions. (#372)
  • Change the output of the tagger code in the Babel plugin so that it doesn't break the output of babel-node. (#374)

3.0.0-beta.4

  • Extends the Babel plugin to enable hot reloading of class properties. (#322)
  • Fixes a bug in the Webpack loader from a component importing a module with the same basename. (#347)

3.0.0-beta.3

  • Fixes broken import of RedBox, which led to confusing stack traces when applications threw errors. (#314)
  • Add module.hot checks to conditional require()s to remove unnecessary warnings when using server rendering. (#302)

3.0.0-beta.2

  • Patch React.createFactory (#287)
  • Fix props typo (#285)

3.0.0-beta.1

  • Adds complete React Router support. Async routes should work fine now. (#272)
  • Fixes a nasty bug which caused unwrapped component to render. (#266, #272)
  • Fixes an issue that caused components with shouldComponentUpdate optimizations not getting redrawn (#269, 2a1e384d54e1919117f70f75dd20ad2490b1d9f5)
  • Internal: a rewrite and much better test coverage.

3.0.0-beta.0

  you now need to write

  ```js
  <AppContainer>
    <App prop={val} />
  </AppContainer>

(#250)

See this commit as an update reference!

3.0.0-alpha

Big changes both to internals and usage. No docs yet but you can look at https://github.com/gaearon/react-hot-boilerplate/pull/61 for an example.

2.0.0-alpha

Experimental release that isn't really representative on what will go in 2.0, but uses the new engine.

Some ideas of what should be possible with the new engine:

  • There is no requirement to pass getRootInstances() anymore, so React Hot Loader doesn't need react/lib/ReactMount or walk the tree, which was somewhat fragile and changing between versions
  • Static methods and properties are now hot-reloaded
  • Instance getters and setters are now hot reloaded
  • Static getters and setters are now hot reloaded
  • Deleted instance methods are now deleted during hot reloading
  • Single method form of autobind-decorator is now supported

What might get broken:

  • We no longer overwrite or even touch the original class. Every time makeHot is invoked, it will return a special proxy class. This means a caveat: for example, static methods will only be hot-reloaded if you refer to them as this.constructor.doSomething() instead of FooBar.doSomething(). This is because React Hot Loader calls makeHot right before exporting, so FooBar still refers to the original class. Similarly, this.constructor === App will be false inside App unless you call App = makeHot(App) manually, which you can't do with React Hot Loader. I'm not sure how much of a problem this will be, so let me know if it pains you. In the longer term, we will deprecate React Hot Loader in favor of a Babel plugin which will be able to rewrite class definitions correctly, so it shouldn't be a problem for a long time. If there is demand, we can introduce a mode that rewrites passed classes, too.

1.3.1

  • Fix import for ReactMount to support 15.4.0 (#430)

1.3.0

  • Recover from module errors on module level (#187)

1.2.9

  • Silently ignore exports that raise an error when accessed (#114)
  • Update source-map dependency

1.2.8

  • Remove React from peerDependencies
  • Update React Hot API to support React 0.14 beta 1

1.2.7

  • Preserve CommonJS exports context in the wrapping closure (#124)

1.2.6

  • Fix autobinding on newly added methods for createClass-style classes

1.2.5

  • Fix “React is not defined” error

1.2.4

  • Avoid updating each class twice in React 0.12

1.2.3

  • Explicitly exclude react/lib files from processing. You should use exclude: /node_modules/ in configuration, but at least this doesn't blow up for those who don't.

1.2.2

  • Fix crash on React 0.13. Now compatible!

1.2.1

  • Don't try to flatten inheritance chains, as it causes problems with super
  • Instead, automatically opt custom base classes into hot reloading as long as they descend from React.Component (in React 0.13). If your custom base class doesn't do that but you'd still want to have hot reloading, you need to manually opt it in via module.makeHot API.

1.2.0

  • Support hot-reloading components without a base class (react-hot-api#5)
  • Support hot-reloading inheritance chains (react-hot-api#10)
  • Support using React 0.13 as an external

1.1.7

  • Add React 0.13 RC2 to peerDeps

1.1.6

  • Allow React 0.13 RC1
  • Better support for ES6 inheritance
  • Fix reloading for modules with null prototype chain (#82)

1.1.5

  • Wrap user code in IEFF to prevent losing "use strict". Fixes #75

1.1.4

  • Fix crash when hot-reloading element factory. (Note: React discourages exporting factories.)

1.1.3

  • Avoid warnings on React 0.13

1.1.2

  • Compatibility with React 0.13.0-beta.1

1.1.1

  • Fix edge cases by requiring react/lib/ReactMount in transformed source files
  • Add a warning if ReactMount doesn't return anything useful (e.g. when using external React)

1.1.0

  • Skipping node_modules entirely wasn't the best idea. Instead, we now specifically skip node_modules/react/, node_modules/webpack/ and node_modules/react-hot-loader/. However you are still encouraged to add exclude: /node_modules/ to your loader config for best performance.
  • Now modules that don't export any valid React classes in module.exports or any its properties will not be auto-accepted. This prevents hot loader from trying to handle non-React updates and allows changes in plain JS files to propagate to components that can handle them. For example, this allows react-jss mixin to apply hot updates to JSS styles.

1.0.7

  • Skip node_modules entirely. Fixes #54 on Windows.

1.0.6

  • Add require('react-hot-loader/Injection') to override Hot Loader behavior. Now you can supply your own way of getting root component instances, so Hot Loader can also work in environment where require('react/lib/ReactMount') is not available (for example, when React is used as standalone bundle and not NPM package).

1.0.5

  • Fix stack overflow when hotifying same class twice (#52)

1.0.4

  • Allow both module.exports and its properties be components (Fixes #50)

1.0.3

  • In addition to hotifying module.exports by default, also hotify all its own properties

1.0.2

  • Don't try to hot-replace module.exported ReactElements

1.0.1

  • Delay requireing ReactMount to avoid circular dependencies
  • Don't process React or Webpack internals to avoid potential issues

1.0.0

  • Don't rely on createClass regex or any other regex
  • Only module.exports is hot by default
  • Supports ES6 classes when they land in React 0.13
  • Supports dynamically created classes
  • Manual mode

See what changed and how to migrate to 1.0.

0.5.0

0.4.5

  • Collapse all hot loader code in one line so it doesn't obscure beginning of file.

0.4.4

  • Errors occuring in module definition (such as ReferenceError) should not disable further reloading (fixes #29)

0.4.3

  • Support lowercase react reference name and usage with ES6 classes (createClass(MyComponent.prototype)) via #27

0.4.2

  • Catch errors in modules and log them instead of reloading (fixes #21)

0.4.1

0.4.0

  • Ignore files that contain no createClass calls (fixes #17)
  • Remove the need for pitch loader (fixes #19)
  • Improve performance by only using one loader instead of two
  • Now that performance is acceptable, remove desktop notifications and notify option
  • It is now recommended that you use devtool: 'eval' because it's much faster and has no downsides anymore

0.3.1

  • Avoid warnings on old browsers with missing Notification API
  • Errors don't cause page reload anymore

0.3.0

  • Use React 0.11