Skip to content

Latest commit

 

History

History

This means that all data in an application follows the same lifecycle pattern, making the logic of your app more predictable and easier to understand. It also encourages data normalization, so that you don't end up with multiple, independent copies of the same data that are unaware of one another.

The user clicks a button in the app and a component prop is called like a function.

The corresponding container dispatches an action. This happens because the prop (which was just called in the container) is tied to an action dispatcher using mapDispatchToProps (in the container).

(Containers are a gateway between State and Components. They take a piece of State from the Store and pass it into a Component as props using the mapStateToProps() method. The mapStateToProps() method accepts the state and returns only the relevant bits of state we need.)

A reducer ‘hears’ that action and runs a function which returns a new state with specific modifications.

The container ‘knows’ that state has changed and modifies a specific prop in the component as a result of the mapStateToProps function.

The component now has a prop that has officially changed due to a new state being generated, so if that prop is responsible for any any visible UI, the user will see it change automatically.

alt text