Skip to content

Commit afabaf2

Browse files
committed
fix proverbs state
1 parent 6ec8b7d commit afabaf2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function YourMainContent({ themeColor }: { themeColor: string }) {
6262
handler: ({ proverb }) => {
6363
setState({
6464
...state,
65-
proverbs: [...state.proverbs, proverb],
65+
proverbs: [...(state.proverbs || []), proverb],
6666
});
6767
},
6868
});
@@ -99,7 +99,7 @@ function YourMainContent({ themeColor }: { themeColor: string }) {
9999
<button
100100
onClick={() => setState({
101101
...state,
102-
proverbs: state.proverbs?.filter((_, i) => i !== index),
102+
proverbs: (state.proverbs || []).filter((_, i) => i !== index),
103103
})}
104104
className="absolute right-3 top-3 opacity-0 group-hover:opacity-100 transition-opacity
105105
bg-red-500 hover:bg-red-600 text-white rounded-full h-6 w-6 flex items-center justify-center"

0 commit comments

Comments
 (0)