Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 185aaa9

Browse files
committed
Add initial count to likes
1 parent 02bd9fb commit 185aaa9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/components/useLikes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ type LikeData = {
55
count: number
66
hasLiked: boolean
77
}
8-
const initialState: LikeData = { count: 0, hasLiked: false }
98

109
function reducer(state: LikeData, action: { type: string; payload?: any }) {
1110
switch (action.type) {
@@ -39,6 +38,7 @@ export function useLikes({
3938
body: any
4039
}
4140
}) {
41+
const initialState: LikeData = { count: initialCount, hasLiked: false }
4242
const { isLoading, isError, data } = useQuery(query.key, () => {
4343
return fetch(query.endpoint, {
4444
method: 'POST',

0 commit comments

Comments
 (0)