Skip to content

Commit 065dda7

Browse files
author
Kubit
committed
Improve useManageState hook
1 parent 06cceda commit 065dda7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/hooks/useManageState/useManageState.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,12 @@ export const useManageState = ({
5454
const setRef = useCallback(node => {
5555
if (node) {
5656
innerRef.current = node;
57-
if (props.states.includes(STATES.HOVER)) {
58-
innerRef?.current?.addEventListener('mouseover', onMouseOver);
59-
innerRef?.current?.addEventListener('mouseout', onMouseOut);
60-
}
6157
if (props.states.includes(STATES.PRESSED)) {
6258
innerRef?.current?.addEventListener('mousedown', onMouseDown);
6359
innerRef?.current?.addEventListener('mouseup', onMouseUp);
60+
} else if (props.states.includes(STATES.HOVER)) {
61+
innerRef?.current?.addEventListener('mouseover', onMouseOver);
62+
innerRef?.current?.addEventListener('mouseout', onMouseOut);
6463
}
6564
} else {
6665
// delete over listeners

0 commit comments

Comments
 (0)