Skip to content
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

@action @observable not work in @observer Class Component #3807

Closed
lgl017temp opened this issue Dec 10, 2023 · 4 comments
Closed

@action @observable not work in @observer Class Component #3807

lgl017temp opened this issue Dec 10, 2023 · 4 comments
Labels

Comments

@lgl017temp
Copy link

lgl017temp commented Dec 10, 2023

Intended outcome:

comp1 color will change to green
comp2 click2 will not warning

Actual outcome:

comp1 color not change until forceUpdate
comp2 click2 warning not in a action

How to reproduce the issue:

demo

Versions

"mobx": "^6.12.0",
"mobx-react": "9.1.0",
"react": "18.2.0",
"react-dom": "18.2.0"

@mweststrate
Copy link
Member

Stupid question maybe, but how can I preview the app? There used to be a preview to the side in codesandbox as far as I remember, but I don't see it:
image

@mweststrate
Copy link
Member

In general this sounds like a transpilation setup issue (e.g. using loose instead of strict class field transpilation), but since the sandbox doesn't expose any configuration it is hard to tell.

@lgl017temp
Copy link
Author

Sorry, I never realized it's broken, demo updated now, run dev to preview
I just use Vite + React + TS template and add tsDecorators in vite.config.ts

@lgl017temp
Copy link
Author

lgl017temp commented Dec 16, 2023

Oh, I realized the class with @observer also need makeObservable(this)
Is it better to show this in the decorator documentation?
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants