Redux learning

April 17, 2023 1345hotness 0likes 0comments

I. what is redux

Redux is a JavaScript container for state management. Redux supports other interface libraries besides being used with React, and its volume is only about 2kb

.

three cores of Redux

  • single data source
    • the state of the entire application is stored in an object tree, and this object tree exists only in the only store .
  • State is read-only
    • the only way to change state is to trigger & nbsp; action , which is a normal object used to describe events that have occurred.
  • use pure functions to perform modifications
    • to describe how action changes state tree, you need to write & nbsp; reducers .

Redux composition

  • State status

    • state, ui state, global state returned by the server
  • action event

    • is essentially a js object
    • needs to include the type attribute
    • describes what is going to happen, but does not describe how to update state
  • reducer

    • is essentially a function
    • response to the action sent
    • The

    • function takes two parameters, the first initializing state and the second sending action
    • must have a return return value
  • Store

    • maintain the state (status) of the application (state, ui state, global state returned by the server)
    • provide getstate method to read state
    • used to associate action with reducer
    • build store through createStore
    • register to listen through subscribe
    • dispatch method to send action
InterServer Web Hosting and VPS

Aaron

Hello, my name is Aaron and I am a freelance front-end developer

Comments