Little dependency array fix
This commit is contained in:
parent
0507309ab1
commit
ddb393be50
1 changed files with 7 additions and 7 deletions
|
@ -47,6 +47,10 @@ function useGameEvent(count: number) {
|
|||
.reduce((prev, curr) => [...prev, ...curr], [])
|
||||
}, [mode])
|
||||
|
||||
const isHit = useCallback((x: number, y: number) => {
|
||||
return hits.filter(h => h.x === x && h.y === y)
|
||||
}, [hits])
|
||||
|
||||
const settingTarget = useCallback((isGameTile: boolean, x: number, y: number) => {
|
||||
if (!isGameTile || isHit(x, y).length)
|
||||
return
|
||||
|
@ -64,16 +68,12 @@ function useGameEvent(count: number) {
|
|||
|
||||
}
|
||||
})
|
||||
}, [count, hits, targetList])
|
||||
}, [count, isHit, targetList])
|
||||
|
||||
const isSet = useCallback((x: number, y: number) => {
|
||||
return !!targetList(target).filter(field => x === field.x && y === field.y).length && target.show
|
||||
}, [target, targetList])
|
||||
|
||||
const isHit = useCallback((x: number, y: number) => {
|
||||
return hits.filter(h => h.x === x && h.y === y)
|
||||
}, [hits])
|
||||
|
||||
const composeTargetTiles = useCallback((target: Target): PointerProps[] => {
|
||||
const { preview, show } = target
|
||||
const result = targetList(target).map(({ x, y, type, edges }) => {
|
||||
|
@ -88,7 +88,7 @@ function useGameEvent(count: number) {
|
|||
}
|
||||
})
|
||||
return result
|
||||
}, [hits, isSet, targetList])
|
||||
}, [isHit, isSet, targetList])
|
||||
|
||||
// handle visibility and position change of targetPreview
|
||||
useEffect(() => {
|
||||
|
@ -101,7 +101,7 @@ function useGameEvent(count: number) {
|
|||
setTargetPreview(e => ({ ...e, show: false }))
|
||||
if (!show && mouseCursor.shouldShow && eventReady && appearOK && !isHit(x, y).length && !isSet && !hasLeft)
|
||||
setTargetPreview(e => ({ ...e, show: true }))
|
||||
}, [targetPreview, mouseCursor.shouldShow, hits, eventReady, appearOK, lastLeftTile, target])
|
||||
}, [targetPreview, mouseCursor.shouldShow, isHit, eventReady, appearOK, lastLeftTile, target])
|
||||
|
||||
// enable targetPreview event again after 200 ms.
|
||||
useEffect(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue