custom hook for react
yarn add uni-hook or npm install uni-hook
import { useCounter } from 'uni-hook'
function Counter() {
const [count, { increment, incrementBy, decrement, decrementBy }] = useCounter(0)
return (
<div>
<div className="mr-bt">Count: {count}</div>
<Button onClick={() => increment()} className="Button">้ไธ้ๅข</Button>
<Button onClick={() => incrementBy(5)} className="mr-20 Button">้ไบ้ๅข</Button>
<Button onClick={() => decrement()} className="mr-20 Button">้ไธ้ๅ</Button>
<Button onClick={() => decrementBy(5)} className="mr-20 Button">้ไบ้ๅ</Button>
</div>
)
}
- useCounter
- useActive
- useBottomVisible
- useDarkMode
- useDelay
- useFocus
- useInScreen
- useInterval
- useKeyPress
- useLockBodyScroll
- useMousePosition
- usePrevious
- useRandomColor
- useTimer
- useToCase
- useToggle
- useWindowSize
- useSessionStorage
- useLocalStorage
- usePromise
- useDidMount
- useHover
- useTouch
- useUndo
- useDimensions
- useOnce
- useImage
- useEventListener