Skip to content

Commit

Permalink
ensuring we are not adding the same item again in local watchlist
Browse files Browse the repository at this point in the history
  • Loading branch information
mnsrulz committed Nov 10, 2024
1 parent 929a89c commit 8d01083
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export const useMyLocalWatchList = (initialState: SearchTickerItem[]) => {

const addToMyList = (item: SearchTickerItem) => {
setWl(v => {
v.push(item)
return v;
const items = v.filter((ticker) => ticker.symbol != item.symbol); //ensuring we are not adding the same item again.
items.push(item);
return items;
});
}

Expand Down

0 comments on commit 8d01083

Please sign in to comment.