Mediator patten for react components

Viewed 1139

I would like to know how we can apply mediator pattern to react components.

For example I have a set of buttons like Activate, De-Activate, Reset etc for different forms. I want to implement a mediator pattern so that I will not have to handle these buttons manually for each form.

Mediator should notify the buttons to be enable/disable/ or change label.

Please share if anyone have implemented something like this.

1 Answers

React is a functional framework, so trying to wholesale apply OOP design patterns isn't going to quite fit.

That said, what you're probably looking for is the Flux design pattern, which is the commonly approved way of managing global state for a react app. There are many libraries that provide implementations of the pattern, but the most popular is probably Redux.

Related