How to extend an existing observable with a getter computed #3541
Unanswered
stellarhoof
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Can you provide a minimal reproduction?
…On Wed, 12 Oct 2022, 21:55 Alejandro Hernandez, ***@***.***> wrote:
I'm able to use this pattern in mobx 4
let m = require('mobx')
let a = m.observable({ a: 1 }, {})
m.extendObservable(a, {
get hidden() {
return true
},
})
However, it gives me this error when migrating to mobx6
Uncaught Error: [MobX] Cannot apply 'true' to ***@***.***':
The field is already annotated with 'true'.
Re-annotating fields is not allowed.
Use 'override' annotation for methods overriden by subclass.
at die (/Users/ah/Code/smartprocure/spark/node_modules/mobx/dist/mobx.cjs.development.js:91:11)
at assertAnnotable (/Users/ah/Code/smartprocure/spark/node_modules/mobx/dist/mobx.cjs.development.js:5994:5)
at ObservableObjectAdministration.extend_ (/Users/ah/Code/smartprocure/spark/node_modules/mobx/dist/mobx.cjs.development.js:5530:5)
at /Users/ah/Code/smartprocure/spark/node_modules/mobx/dist/mobx.cjs.development.js:3056:11
at Array.forEach (<anonymous>)
at Object.extendObservable (/Users/ah/Code/smartprocure/spark/node_modules/mobx/dist/mobx.cjs.development.js:3055:26)
—
Reply to this email directly, view it on GitHub
<#3541>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBDMNP5BSBLL4AGPMULWC4JRRANCNFSM6AAAAAARDTN744>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Can't reproduce https://codesandbox.io/s/extendobservable-todo-del-u13w5p |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm able to use this pattern in mobx 4
However, it gives me this error when migrating to mobx6
What's the idiomatic way of extending an observable with a getter?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions