-
Notifications
You must be signed in to change notification settings - Fork 642
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
in
operator regression for actions
#1639
Comments
This reverts commit 850d002. There is a regression in mobx-state-tree where `'setIsStatic' in selectedEntity` does not work anymore. See mobxjs/mobx-state-tree#1639
Diff v4.0.2 with v4.0.3Github code diff link - import { isObservableArray, $mobx, getAtom } from "mobx"
+ import { isObservableArray, _getGlobalState, getAtom } from "mobx"
- export const mobxShallow =
- typeof $mobx === "string" ? { deep: false } : { deep: false, proxy: false }
+ export const mobxShallow = _getGlobalState().useProxies
+ ? { deep: false }
+ : { deep: false, proxy: false } The $mobx in mobx6 is a Symbol export const $mobx = Symbol("mobx administration") 🔥 When we use modern browser which support Proxy 🔥typeof $mobx === "string" is false in v4.0.2 v4.0.2 mobxShallow = { deep: false, proxy: false }v4.0.3 mobxShallow = { deep: false }Reproduction Examplev4.0.2 The john object is a plain object v4.0.3 The john object is a Proxy object Proxy MDN doc Mobx Proxy process code: mobx/packages/mobx/src/types/dynamicobject.ts has(target: IIsObservableObject, name: PropertyKey) {
if (name === $mobx || name === "constructor") return true
if (__DEV__ && globalState.trackingDerivation)
warnAboutProxyRequirement(
"detect new properties using the 'in' operator. Use 'has' from 'mobx' instead."
)
const adm = getAdm(target)
// MWE: should `in` operator be reactive?
// If not, below code path will be faster / more memory efficient
// check performance stats!
// if (adm.values.get(name as string)) return true
if (isStringish(name)) return adm.has_(name)
return (name as any) in target
} So when we use v4.0.3 console.log('setName' in john); will print false in console.... |
I think this is an issue for views too, not just actions. I can confirm it only happens for me when proxies are used. Is this maybe a plain |
@airhorns @getkey It's existing Mobx6 issue |
It has nothing to do with enumerability, but should be fixed by: |
Should work with MobX 6.1.* (MST > 5.0.1) |
Yes, fixed by PR 2641! |
Awesome, thanks @urugator! Closing this issue. |
Bug report
I've made sure my project is based on the latest MST versionnot applicableSandbox link or minimal reproduction code
https://stackblitz.com/edit/in-regression-mobx-state-tree?file=index.html
Describe the expected behavior
The
in
operator should detect actions. I've observed that the regression appeared somewhere between version 4.0.2 and 4.0.3.Describe the observed behavior
The
in
operator doesn't detect actions on instances of the model.The text was updated successfully, but these errors were encountered: