Skip to content

Add useDebouncedState and useThrottledState #538

Description

@hyesungoh

The debounce and throttle families have Value and Callback hooks but no State hook. With a State hook, each family covers the three ways to own the state: the hook owns it (*State), the caller passes a value (*Value), or the caller passes a function (*Callback).

Add useDebouncedState and useThrottledState. Each takes an initial value, debounceMs or throttleMs, and the same leading and trailing options as the rest of its family, and returns the current value with a debounced or throttled setter. Follow the return shape that #528 lands on for state hooks with a single setter. Add docs and tests.

Waits for #532 and #534.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions