mirror of
https://github.com/streamich/react-use.git
synced 2025-12-08 18:02:14 +00:00
useVibrate docs
This commit is contained in:
parent
9df69c6e00
commit
24ae8f392c
@ -75,6 +75,7 @@
|
||||
- [`useDrop` and `useDropArea`](./docs/useDrop.md) — tracks file, link and copy-paste drops.
|
||||
- [`useFullscreen`](./docs/useFullscreen.md) — display an element or video full-screen. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/ui-usefullscreen--demo)
|
||||
- [`useSpeech`](./docs/useSpeech.md) — synthesizes speech from a text string. [![][img-demo]](https://codesandbox.io/s/n090mqz69m)
|
||||
- [`useVibrate`](./docs/useVibrate.md) — provide physical feedback using the [Vibration API](https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API). [![][img-demo]](https://streamich.github.io/react-use/?path=/story/ui-usevibrate--demo)
|
||||
- [`useVideo`](./docs/useVideo.md) — plays video, tracks its state, and exposes playback controls. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/ui-usevideo--demo)
|
||||
- [`useWait`](./docs/useWait.md) — complex waiting management for UIs.
|
||||
<br/>
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
# `useVibrate`
|
||||
|
||||
React UI hook to provide physical feedback with device vibration hardware using the [Vibration API](https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API).
|
||||
|
||||
## Usage
|
||||
|
||||
```jsx
|
||||
import {useVibrate} from 'react-use';
|
||||
|
||||
const Demo = () => {
|
||||
const [vibrating, toggleVibrating] = useToggle(false);
|
||||
|
||||
useVibrate(vibrating, [300, 100, 200, 100, 1000, 300], false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button onClick={toggleVibrating}>{vibrating ? 'Stop' : 'Vibrate'}</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
```ts
|
||||
useVibrate(
|
||||
enabled: boolean = true,
|
||||
pattern: number | number[] = [1000, 1000],
|
||||
loop: boolean = true
|
||||
): void;
|
||||
```
|
||||
Loading…
x
Reference in New Issue
Block a user