When you choose not to use Flux / Redux , here is what you do:
Create an external component that should wrap all other components. This component is also known as a higher order component or controller view. This component should use the HTTP library to communicate with your microservices (I personally like Axios ). I would recommend creating a client API that wraps Axios. Your higher-order component can reference this client API, so it is an agnostic of the HTTP library and whatnots. I would also put a link to this client API on a window object in dev mode so that you can do window.clientApi.fetchSomething() in the Chrome console and make debugging easier.
Do all the rest of the components (ChatBox, AvatarBox and NewsStream) . If you are not familiar with this concept, this means that they get everything they need through props , and they avoid saving the state. These components should not cause the microservices themselves. This is a responsibility of a higher order. To be interactive, these components must receive event handlers as props.
It is right? It will provide pure responsibility for managing the models, but it does give performance problems using HTTP requests to load each component content.
You can avoid performance issues with help by not allowing each component to access microservices directly . If your higher order component compiles all the necessary information and makes as few HTTP calls as possible, you should be fine with this approach.
Using Flux / Redux is usually recommended, but if you refuse, here is how to do it.
André pena
source share