How to make a shared state between two react components?

The dependency type between the components will define the best approach.

For instance, redux is a great option if you plan to have a central store. However other approaches are possible:

  • Parent to Child

    1. Props
    2. Instance Methods
  • Child to Parent

    1. Callback Functions
    2. Event Bubbling
  • Sibling to Sibling

    1. Parent Component
  • Any to Any

    1. Observer Pattern
    2. Global Variables
    3. Context

Please find more detailed information about each of the approaches here

Leave a Comment