Skip to content

Commit

Permalink
여러 번 뜨는 거 안 하게
Browse files Browse the repository at this point in the history
  • Loading branch information
xnuk committed May 21, 2022
1 parent 4b88351 commit 3bd936d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ export const List = () => {
},
)

useEffect(() => {
if (itemName == null) return
setLastItemName(itemName)
}, [itemName])

useEffect(() => {
if (itemName == null) return

Expand All @@ -37,7 +32,17 @@ export const List = () => {
}, [itemName])

useEffect(() => {
if (itemName != null) {
setLastItemName(itemName)
setExistsCache(prev => ({
...prev,
[itemName]: {},
}))
return
}

if (lastItemName == null || exists == null) return

setExistsCache(prev => {
const orig: readonly string[] =
prev[lastItemName]?.[exists.place] || []
Expand All @@ -53,7 +58,7 @@ export const List = () => {
},
}
})
}, [lastItemName, exists])
}, [itemName, lastItemName, exists])

return (
<ul class="item-list">
Expand Down

0 comments on commit 3bd936d

Please sign in to comment.