I'm using mobx v2.3.4 and mobx-react v3.4.0 with React hot reloading. Whenever a React component is hot-reloaded I get the following message:
TypeError: Cannot redefine property: __mobxLazyInitializers
This only started to happen when I upgraded mobx and mobx-react. There was no issue with v2.2.2/v3.3.1. Any idea what could be causing this?
I think this error can be fixed, but in that case I am not sure that the behavior will be correct afterwards, since the HMR support for decorators is limited. Which version of react-hot-loader are you using?
A safer workaround would be to introduce the observable properties in the constructor with extendObservable instead of using decorators.
I'm using [email protected] and [email protected] based on this boilerplate.
I thought it wasn't related to decorators because it only started happening with [email protected].
This was happening to me with react native when using decorators and hot reloading. Using functions instead of decorators solved the problem.
Most helpful comment
I think this error can be fixed, but in that case I am not sure that the behavior will be correct afterwards, since the HMR support for decorators is limited. Which version of react-hot-loader are you using?
A safer workaround would be to introduce the observable properties in the constructor with
extendObservableinstead of using decorators.