@byteclaw/hooks
v1.1.5
Published
Collection of useful React hooks for your applications
Downloads
53
Readme
@byteclaw/hooks
Collection of useful React hooks for your Applications.
Installation
npm install @byteclaw/hooks
yarn add @byteclaw/hooks
Hooks
@byteclaw/use-event-emitter
- React hooks and components for construction of simple event emitters@byteclaw/use-overflow-scroll-position
- React hook for tracking the scroll position inside an overflow:scroll enabled element@byteclaw/use-prompt
- React hook and component for prompting the user to input anything using your custom components.@byteclaw/use-static-callback
- Variations of ReactuseCallback
hook that can be used with function declarations.@byteclaw/use-unique-id
- React hook to generate unique ids for your components
Usage
import { useOverflowScrollPosition } from '@byteclaw/hooks';
import React from 'react';
function ScrollableBox(children) {
const box = useRef(null);
const [scrollPosition, scrollHeight] = useOverflowScrollPosition(box);
if (scrollPosition !== null && scrollPosition === scrollHeight) {
console.log(`You've successfully scrolled to the end, yay!`);
}
return <div ref={box}>{children}</div>;
}