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

Accessing computed properties in combination with extendObservable causes crash #1740

Closed
5 tasks done
deadbeef84 opened this issue Sep 27, 2018 · 1 comment
Closed
5 tasks done

Comments

@deadbeef84
Copy link
Contributor

I have an issue:

  • Provide error messages including stacktrace
TypeError: Cannot read property 'get' of undefined
    at ObservableObjectAdministration$$1.read (VM455 mobx.js:3477)
    at AppState.get (VM455 mobx.js:3737)
  • Provide a minimal sample reproduction.

https://codesandbox.io/s/1ynlm8v7k7

  • Did you check this issue wasn't filed before?

Couldn't find any similar issue.

  • Elaborate on your issue. What behavior did you expect?

Accessing computed properties fails on the second instance. In this minimal reproduction it appears you can access the property after instantiation; however this is not the case in my larger code base (could it be dependent on from where it is instantiated? I'm thinking it's in tracked context in my larger code base).

Workarounds:

  • Using @observable fixes the issue.

  • Accessing the property before extendObservable(...) makes the error go away

    • State the versions of MobX and relevant libraries. Which browser / node / ... version?
  • mobx 5.1.2

  • chrome 69.0.3497.100

  • node 10.9.0

@mweststrate
Copy link
Member

Thanks for the accurate test! Fixed in MobX 4.5.0 / 5.5.0

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

No branches or pull requests

2 participants