Replies: 2 comments 1 reply
-
Hi @TonyJOM ! Please check that your transpiler is configured correctly: https://mobx.js.org/installation.html#use-spec-compliant-transpilation-for-class-properties There is a one-line script to check. For TS you'll probably have to set "useDefineForClassFields": true |
Beta Was this translation helpful? Give feedback.
-
@kubk Thank you for sharing that link. I forgot to mention it in my original post, that I have set "useDefineForClassFields" to true in my tsconfig. The point I was trying to bring up is that in my example, an error is not displayed in that case referring to adding an initializer, but in other cases it does display the error. I also noticed that in the installation guide you posted, it does state that if a class fields is not initialized than it will lose its observable state. This was something I did not notice, since I was migrating from |
Beta Was this translation helpful? Give feedback.
-
Hey! I am in the process of migrating from
mobx
v5 to v6.I have noticed a few things that have changed that I could not find information on in the migration guide. I wanted to bring up these points because I was confused by the change of behavior from
mobx
v5.1.
Observable state is lost in a variable if not initialized in
mobx
v6 but worked perfectly fine before inmobx
v5. No error message is given. I have provided an example below.2.
Going off of the first example which used
npx mobx-undecorate --keepDecorators
, in the second examplenpx mobx-undecorate
is used. In this example, I receive an error message unlike the first example,[MobX] Cannot apply 'observable' to '[email protected]' Field not found.
, when arguably the field is there. I have provided an example below.The reason I bring up these two examples is because I would like to figure out the reason for these changes in
mobx
v6 when they were working fine inmobx
v5? I tried to look around the migration guide to see if there was any mention of these changes, but I wasn't able to find anything. This might be worth adding to the migration guide or somewhere in your docs.Beta Was this translation helpful? Give feedback.
All reactions