DEV Community


Discussion on: Using MobX with React Hooks

ryands17 profile image
Ryan Dsouza Author

I think a better option would be that instead of calling the ToasterStore from your http class, you should call your ToasterStore from the store that you are calling your http class method in. Let's call that the DataStore

In MobX, you can combine the DataStore with your ToasterStore by creating a RootStore as described in this article

After that, call you error message method from the ToasterStore in your DataStore, this will maintain separation of concerns as the http class only now has to worry about fetching data and not update the UI.