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

Doc fix: observable fields is not created #3932

Closed
wants to merge 1 commit into from

Conversation

PredokMiF
Copy link
Contributor

Observable fields is not created if it placed after makeAutoObservable

Copy link

changeset-bot bot commented Oct 5, 2024

⚠️ No Changeset found

Latest commit: fb3f57d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Member

@mweststrate mweststrate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run into this, your compilation setup is incorrect, the declarations at lines 32-34 should have already instantiated the fields in spec compliant class compilation. Please see the setup docs for the right transpiler options.

@PredokMiF
Copy link
Contributor Author

Ok, I will create sandbok for the case to try code

@PredokMiF
Copy link
Contributor Author

Yes, you are right. Some weird default TS settings for vite template react-ts. But from the learning point of view, my MR is still fair, because after makeAutoObservable in strict mode you can only change the referenced values in actions. So it is easier to assign first and then call makeAutoObservable to prevent warnings in console.

@mweststrate
Copy link
Member

That works for simple constructors, but it introduces its own set of problems. E.g. if you introduce branching in the constructor, or call local methods, they might now obtain references to objects before they are turned into observables, etc.

@PredokMiF
Copy link
Contributor Author

Understood. Thank you for your prompt response and clarification. I will close the PR

@PredokMiF PredokMiF closed this Oct 7, 2024
@PredokMiF
Copy link
Contributor Author

It is realy bug of vite. The workaround is contained in the issue

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

Successfully merging this pull request may close these issues.

2 participants