I want to write that the value of state is retrieved from the background when reducer, is initialized. How should it be implemented?
whether to use redux-thunk directly dispatch a function operation interface or state? that dispat already exists when using other action
add:
I want to initialize state, by getting values from the background. All operations on the data are based on this state.
, which is the format of the db.json that fetches the data in the background.
{
"user": [
{
"id": 10000,
"name": "",
"student_id": 2018214001,
"gender": "male"
},
{
"id": 10001,
"name": "",
"student_id": 2018214002,
"gender": "female"
},
{
"id": 10002,
"name": "",
"student_id": 2018214003,
"gender": "female"
}
],
"book": [
{
"id": 10000,
"name": "JavaScript",
"price": 45,
"owner_id": 10000
},
{
"id": 10001,
"name": "Java",
"price": 67,
"owner_id": 10001
}
]
}
what I want to do is to split user and book into two render, that manages two state, respectively and then binds the router to the onEnter event when entering the page, which requests fetch through the store.dispatch (fn ()), fn, and assigns the returned value to state.
I don"t know if this will work, because it"s stuck in the middle, and I don"t know how to say that the merged state is the same as the bd.json format. I"m still a little confused about redux. Thank you for your guidance.