mobxjs / mobx-react-lite

Lightweight React bindings for MobX based on React 16.8 and Hooks
https://mobx.js.org/react-integration.html
MIT License
2.13k stars 90 forks source link

New version (2.x) do not work in React Native with hermes js engine #270

Closed farwayer closed 4 years ago

farwayer commented 4 years ago
 ReferenceError: Property 'Reflect' doesn't exist

Next hermes version will support proxies and reflection. But current is not. Reflect used only once in code: https://github.com/mobxjs/mobx-react-lite/blob/45a58c42bdc4a511d55a512474fd34c4ca3afbcf/src/observer.ts#L91 Can we avoid using it at least until next hermes version will be shipped with React Native?

danielkcz commented 4 years ago

Given that Reflect can be polyfilled I don't think we are going to roll back this change, sorry. The same problem is with IE11 which needs polyfill almost for everything anyway.

mweststrate commented 4 years ago

In this very specific case ( https://github.com/mobxjs/mobx-react-lite/blob/ef91cca9d5fbb09ceaca286d2e21e9549cd19801/src/observer.ts#L91) it seems that condition is not needed anyway, since we are already looping the own properties, so has must always return true here?

On Mon, Apr 6, 2020 at 6:48 PM Daniel K. notifications@github.com wrote:

Given that Reflect can be polyfilled I don't think we are going to roll back this change, sorry. The same problem is with IE11 which needs polyfill almost for everything anyway.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx-react-lite/issues/270#issuecomment-609941570, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBHAGR7WO6TISYXPXOLRLIIYJANCNFSM4MCMROUQ .

danielkcz commented 4 years ago

@mweststrate Hm, Object.keys returns own properties only? That's a new thing for me. I suppose it would make sense then given it's the only occurrence.

farwayer commented 4 years ago

Yep, Object.keys returns keys for object own props only. And in any way you can't check own property with Reflect.has because it uses whole prototype chain.

danielkcz commented 4 years ago

Alright, published 2.0.3 without Reflect.