3 ms·
It was a long time ago I built anything with React but I used to use MobX mostly because of the inject function, to be able to access the global store from any
by Kiro 6y ago
It was a long time ago I built anything with React but I used to use MobX mostly because of the inject function, to be able to access the global store from any component without prop drilling. I don't see much emphasis on that anymore though. Has React incorporated a native function for that? Is it the context API?
Edit: What I don't understand with the context API is that it looks like I need to access the instantiated context externally in every component, while MobX injected it through the component tree automatically.
- nsonha 6y agoyeah I don't understand why the react team made such an API. It's literally service locator an anti-pattern. I started to think maybe it's best not to use mobx nor react for dependency injection and usehigher order functions/components in a poor man's DI manner is the most sustainable way forward. Because you can inverse control everything not just UIs/observables. Or use a separate lib like inversify or aurelia/dependency-injection