1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-05-06 10:06:41 +07:00

refactored hooks directory

This commit is contained in:
Fedor Katurov 2022-01-02 18:17:09 +07:00
parent efa3ba902d
commit f76a5a4798
106 changed files with 122 additions and 144 deletions

View file

@ -0,0 +1,18 @@
import { useCallback, useState } from 'react';
export const useFocusEvent = (initialState = false) => {
const [focused, setFocused] = useState(initialState);
const onFocus = useCallback(
event => {
event.preventDefault();
event.stopPropagation();
setFocused(true);
},
[setFocused]
);
const onBlur = useCallback(() => setTimeout(() => setFocused(false), 300), [setFocused]);
return { focused, onBlur, onFocus };
};