使用函数式的风格访问状态库

This commit is contained in:
jinmiaoluo
2023-04-29 13:30:53 +08:00
committed by Jinmiao Luo
parent bcf09974f5
commit c7965f0e6a

View File

@@ -131,9 +131,9 @@ export const useChatStore = create<ChatStore>()(
}, },
removeSession(index: number) { removeSession(index: number) {
set(() => { set((state) => {
let selectedIndex = get().currentSessionIndex; let selectedIndex = state.currentSessionIndex;
const sessions = get().sessions; const sessions = state.sessions;
if (sessions.length === 1) { if (sessions.length === 1) {
return { return {