When creating a react project, using the react-hot-loader component, the component does not take effect

1. When creating a react project, because the state value of the component will be reset to the initial value when using the webpack-hot-middleware hot update page, the component of react-hot-loader will be used to deal with it, but no matter how to set it, it will not take effect. I don"t know why
2.

webpack

Mar.16,2021

it seems that you didn't use a decorator to wrap the components.

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

export default hot(module)(Counter);

or decorator syntax for the stage phase, which requires additional plug-ins for babel

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


@hot(module)
export default Counter extends Component {}
Menu