One of the best features of React is that it helps you build a componentized app. You can build smaller components, each with its own responsibility, and then combine them to create a complete app. Often these components need to communicate with each other to pass data around the app.

React uses props to communicate between dependent components. Still, there are instances when you might want to communicate between two independent components that don’t have a common functionality to share data. In this guide, you will learn how to communicate between independent components using an event bus.

To communicate between two independent components in React, you have the flexibility to set up a global event-driven system, or a PubSub system. An event bus implements the PubSub pattern and allows you to listen and dispatch events from components. The event bus helps you to decouple your components and pass data using events fired from other components so that they don’t have direct dependencies between each other…

#react #javascript

How to Communicate between Independent Components in React
14.00 GEEK