Skip to content

Commit

Permalink
fix: update logic to handle index of 0 (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
MonsterPi13 authored Jan 26, 2024
1 parent aec284e commit c24762b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hooks/useViewData.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const useViewData = (slug) => {
setViewData((prev) => {
if (!prev) return null
const index = prev.findIndex((item) => item.slug === payload.new.slug)
if (index) index !== -1 ? (prev[index] = payload.new) : prev.push(payload.new)
index !== -1 ? (prev[index] = payload.new) : prev.push(payload.new)
return [...prev]
})
}
Expand Down

1 comment on commit c24762b

@vercel
Copy link

@vercel vercel bot commented on c24762b Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.