
Why I Switched from MobX to easy-model (And Why You Might Too)
Why I Switched from MobX to easy-model MobX was my go-to for class-based state management. Until I found something better. My MobX Journey Started with MobX 4, migrated to MobX 6. Used decorators everywhere: class OrderStore { @ observable orders : Order [] = []; @ observable loading = false ; @ computed get totalAmount () { return this . orders . reduce (( sum , o ) => sum + o . amount , 0 ); } @ action async fetchOrders () { this . loading = true ; try { const res = await api . getOrders (); runInAction (() => { this . orders = res . data ; }); } finally { runInAction (() => { this . loading = false ; }); } } } Then TypeScript started complaining. Then decorators got deprecated. Then I had to rewrite everything with makeAutoObservable . The MobX Pain Points 1. Type Inference Hell // This should work but doesn't const orders = store . orders . map (( o ) => o . items ); // TypeScript: "Object is of type 'unknown'" class Store { @ observable map = new Map < string , Order > (); getOrde
Continue reading on Dev.to React
Opens in a new tab




