uni-hook
v1.3.3
Published
custom-hook
Downloads
9
Readme
uni-hook
custom hook for react
Install
yarn add uni-hook or npm install uni-hook
Usage
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>
)
}
All Hook
- 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