Open ChanwooLucioLee opened 3 years ago
I agree with your point that edit and delete would be implemented much easily. However, I guess there are some points we have to consider.
In that case, how does add work? In the previous reducer, add was done by adding the new element to the original array by [...state, newItem]. When the states are in a object form, do we have to change it to a list first to add it?
If we change the format, I guess then we should change the syntax of not only the reducers but also testing codes, as I have already finished testing on all the actions and reducers. If we change the format before sprint 4 ends, I guess we have to change all the testing codes also. Would the changes be minimal? Do we have enough time to do this?
[...state, [action.payload.id]: action.payload} will do
I will not change code for goals and tasks. The new format will only apply to achievements.
We have stored objects in an array in reducers in frontend. For example, the initial state of "goals" in goalReducer is [], which is an array.
However, we will start to store objects in an object with its id as a key. For example, goals = [{'id': 1, 'title': 'TITLE1'}, {'id': 2, 'title': 'TITLE2'}] will be stored as goals = {1: {'id': 1, 'title': 'TITLE1'}, {'id': 2, 'title': 'TITLE2'}}
Why is it better?
How to migrate?
I cannot terminate the list.
Precaution: there might be issues during migration. Please check the format of the data you are using is what you expected.