@horat1us/react-hooks
v1.13.0
Published
React Hooks Collection
Downloads
64
Maintainers
Readme
React Hooks
Collection of React Hooks and Utils
Install
npm i @horat1us/react-hooks
Usage
import { useOpenState } from "./src";
export const Component = () => {
const [isOpen, changeOpenState] = useOpenState();
return (
<button className={isOpen ? "is-open" : "is-close"} onClick={changeOpenState}>
{isOpen ? "Close" : "Open"}
</button>
);
};
Contents
- useOpenState
- useWindowWidth
- useWindowSize
- useInterval
- useTimeout
- useSubmitCallback - handle FormEvent with custom callback
and
event.preventDefault()
call. - useInputState - controlling input value using state and onChange callback.
- useScrollEffect - auto scroll to element bottom on changes
- useMutationObserver - MutationObserver effect hook with HTMLElement state
- useDocumentTitleEffect - auto scroll to element bottom on changes. Can be used as stateless component:
<DocumentTitle value="string" />
- usePageMeta - changes or adds meta tag.
- usePageInfo - combines useDocumentTitleEffect and usePageMeta.
- useMounted - returns isMounted value for current component using useRef and useEffect.
- usePrint - prints selected DOM element. When use you may use printable.min.css.