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