-
-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking changes in Mobx 6 #553
Comments
Hello @ajorkowski |
This might need a breaking version of mobx-react-form? |
Yes I don't see any other way to do it. |
I'm trying to update the code but I encountered an issue:
|
So I think this might be related to how you are supposed to call According to the docs (and the changes I made in my own code), the base class has to call So in our case you might have constructors that look like:
Or is this what you are doing and still getting the error? I guess it might be a bug in mobx then :/ |
Yes, that's exactly what I did, I have added it in the Base class as well. |
Hrm, I was doing more research on this, and they have a page specifically for decorator support. It looks like they expect babel 7 to be used, and there is a difference in the configuration used: https://mobx.js.org/enabling-decorators.html#babel-7 I'm thinking this is causing the issue - you are using babel 6 which I believe has the equivalent configuration as the expected config with babel 7 for the old mobx, but this new version of mobx uses the alternative class-properties:
I guess this makes the upgrade path a bit tricky - ie upgrade to babel 7 (@babel packages), and have a different config for mobx 6 vs others, but this would mean a different build based on the version of mobx at the end of the day.... :( |
@foxhound87 @ajorkowski What do you think about upgrading Babel to 7, MobX to 6 and releasing a new major version of mobx-react-form without support for older versions of MobX? I did it in my fork and I can create the PRs (all tests are green except the performance test).
|
@vkrol wow awesome, thanks for doing those changes. They look good to me. The only question I would have is why add the |
@ajorkowski Yes, of course, thank you! I forgot to delete it. I will update it a bit later. UPD: done. |
I created "draft" versions of PRs for visibility: |
I think making a new major version here is the right way to go. MobX 3 definitely doesn't need to be supported anymore, and the functionality of 4 and 5 is encapsulated by 6. (including IE support, the only thing worth using Mobx 4 for.) I'm unable to upgrade MobX in my own project until this is done. |
The mobx6 support has been released in version 3 |
Unfortunately there has been a breaking change with mobx 6 -
makeObservable(this)
will have to be added to the constructor of any classes that are using the@observable
,@action
or@computed
decorators.More information and example here:
https://mobx.js.org/enabling-decorators.html
Alternatively the decorators can be removed entirely and
makeObservable
can be used with a second parameter, which is described in the upgrade guide:https://mobx.js.org/migrating-from-4-or-5.html#upgrading-classes-to-use-makeobservable
I'm not sure which method you would prefer?
Cheers,
Felix
The text was updated successfully, but these errors were encountered: