Reference:
https://redux.js.org/tutorials/essentials/part-1-overview-concepts
Redux is a pattern and library for managing and updating application state, using events called "actions".
It serves as a centralized store for state that needs to be used across
your entire application, with rules ensuring that the state can only be
updated in a predictable fashion.
Redux is more useful when:
- You have large amounts of application state that are needed in many places in the app
- The app state is updated frequently over time
- The logic to update that state may be complex
- The app has a medium or large-sized codebase, and might be worked on by many people
Not all apps need Redux.
type and payload in Redux:
Payload is what is keyed ( the key value pairs ) in your actions and passed around between reducers in your redux application. For example -
const someAction = {
type: "Test",
payload: {user: "Test User", age: 25},
}
This is a generally accepted convention to have a type and a payload for an action. The payload can be any valid JS type ( array , object, etc ).
Reference:
https://stackoverflow.com/questions/51357412/what-is-a-payload-in-redux-context
No comments:
Post a Comment