Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
fix: scoreの上限を設定
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Kizuku committed Aug 18, 2024
1 parent d99275b commit 71f8a08
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/store/useScoreStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ type Action = {
export const useScoreStore = create<State & Action>()((set) => ({
score: 0,
setScore: (score) => set(() => ({ score: score })),
addOneScore: () => set((state) => ({ score: state.score + 1 })),
addOneScore: () =>
set((state) => {
if (state.score > 3) {
return { score: 3 };
}
return { score: state.score + 1 };
}),
}));

0 comments on commit 71f8a08

Please sign in to comment.