At the beginning, there was a problem in using redux, to use redux to add, delete, check and correct data.

I have been studying redux for several days, and I am doing a redux dome, that adds, deletes, checks and modifies the data. I follow the tutorials I am looking for on the Internet, but I don"t understand.
so now there are several mistakes and there is no way to start

this is action

clipboard.png

reducer

clipboard.png

there is no problem with adding data, but there is a problem with deleting and modifying. Delete function deletes all data,

Delete function deletes all data because there is no return, and return is normal

when you modify the data, all the data will be modified, and you have no idea what went wrong

.

the case for modifying data is return, but all data will be modified

Mar.02,2021

filter uses the es6 syntax, and then adds a parenthesis. Don't you need to write a return?


you should also pay attention to this pile of English spelling problems. Let others visit
in the cloud for a second time, and then your revise and remove do not have return {.state,}
add and default, so there is no problem


deleting, adding, and modifying
are all for an object, so all you need is a reducer .
reducer is only responsible for updating state , not dealing with business logic.
all business logic should be handled in action .

if state= {list: []}
then:

addAction = (obj) => {
    list.push(obj);
    return {
        type: 'listReducer',
        list
    }    
}

the same is true for deletions and modifications. All you need to do with list, in action is return to the same reducer .


let result= item=list.item.

Menu