Mobx: TypeError: Cannot redefine property: __mobxLazyInitializers

Created on 7 Jul 2016  路  3Comments  路  Source: mobxjs/mobx

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?

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 extendObservable instead of using decorators.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hellectronic picture hellectronic  路  3Comments

ansarizafar picture ansarizafar  路  4Comments

thepian picture thepian  路  3Comments

jamiewinder picture jamiewinder  路  4Comments

giacomorebonato picture giacomorebonato  路  3Comments