gpt4 book ai didi

javascript - 终极版 : reset 1 variable to initial state in Redux

转载 作者:行者123 更新时间:2023-12-01 01:42:51 28 4
gpt4 key购买 nike

我有一个应用程序,我正在使用 redux 来管理状态,我想将仅 1 个变量的状态清除为初始状态。

I need to make the new albums state to initial state only that not others , if anyone know please let me know

export default {
loading: true,
error: null,
albums: [],
page: 1,
lastId: '',
totalRecord: 0,
album: {
loading: true,
error: null,
message: null,
album: null,
},
newAlbum: {
album_id: null,
images: [],
totalImages: 0,
currently_uploading: 0,
}
};

最佳答案

只需将此案例添加到您的 reducer 中即可:

case 'CLEAR_NEW_ALBUM':
return { ...state, newAlbum: INITIAL_STATE.newAlbum }

关于javascript - 终极版 : reset 1 variable to initial state in Redux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52256327/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com