use-hold-repeat
Repeats an action while a control is held down
Source
Package
Usage
use-hold-repeat calls a function once, then repeats it at a fixed or accelerating interval
until it is stopped. The hook does not attach DOM events: call start and stop from your own
handlers, or use use-hold-repeat-handlers to get them ready-made:
Count: 0
Definition
Repeat is opt-in
By default, start calls the function once. To repeat it, set both delay and interval.
delay is the pause before the first repeat, interval is the time between the following ones:
Accelerating interval
Pass a function to interval to calculate the delay before each repeat from the number of calls
made so far. count starts at 2: the first call is the immediate one, the second is the first repeat.
Cleanup
The timer is cleared automatically when the component unmounts.
Exported types
UseHoldRepeatInterval, UseHoldRepeatOptions and UseHoldRepeatReturnValue types are exported
from the @mantine/hooks package: