Reputation: 150966
Since Redux is just the one and only (and the main) data store for the whole app, can we pass data from
just by emitting an action with data to generate a new app state to be able to pass the data?
Upvotes: 0
Views: 156
Reputation: 4748
Let's start from the beginning.
Why we use Redux?
Redux is an open-source JavaScript library for managing application state. It is most commonly used with libraries such as React or Angular for building user interfaces. Redux comes in the scenario when we want to share state between components by having a single source of truth. It creates only one centralized store
that holds the data.
Passing data from child component to parent component
If you want to pass the data from child component to parent component, you can do that without redux
via props.
Passing data from child to sibling components
If you want to pass the data from child to sibling components, there are two ways. Either use redux
store or lift the state up and pass it as props
from child parent.
or any component to any other component
It depends where the component is, do they have any connection like (Parent-Child), if yes then props
otherwise redux
store.
Upvotes: 1