I'm trying out decorator for React Native but having a problem right now. The decorator function is only called once. If I assign something on the class property, the decorator doesn't get called. It works on Typescript Playground though. Here's my sample code: Sample Code Link To Typescript Playground
class VM { @ReactiveState() count = 1;}function ReactiveState() { return function(target: any, key: string | symbol) { let val = target[key]; const getter = () => { return val; }; const setter = (next: number) => { console.log('updating flavor...'); val = `🍦 ${next} 🍦`; }; Object.defineProperty(target, key, { get: getter, set: setter, enumerable: true, configurable: true, }); console.log({val}) }}const vm = new VM();vm.count = 5;console.log({count: vm.count })// Result in React Native Metro Bundler Terminal: // { "count": 5 }// Result in Typescript Playground// { "count": "🍦 5 🍦" }vm.count = 6;console.log({count: vm.count })// Result in React Native Metro Bundler Terminal: // { "count": 6 }// Result in Typescript Playground// { "count": "🍦 6 🍦" }