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

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) {
set(() => {
let selectedIndex = get().currentSessionIndex;
const sessions = get().sessions;
set((state) => {
let selectedIndex = state.currentSessionIndex;
const sessions = state.sessions;
if (sessions.length === 1) {
return {