|
Download react-use/docs/useVibrate.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 650 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useVibrate.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-use/docs/useVibrate.md
-
curl -L -o useVibrate.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useVibrate.md
650 Bytes
useVibrate
React UI hook to provide physical feedback with device vibration hardware using the Vibration API.
Usage
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
useVibrate(
enabled: boolean = true,
pattern: number | number[] = [1000, 1000],
loop: boolean = true
): void;