Skip to content

Instantly share code, notes, and snippets.

@gaperton
Created May 8, 2019 04:49
Show Gist options
  • Save gaperton/4f0ac8d5a44bfd60cfd782eea66af1b3 to your computer and use it in GitHub Desktop.
Save gaperton/4f0ac8d5a44bfd60cfd782eea66af1b3 to your computer and use it in GitHub Desktop.
export const DelayedInput = ({ $value, timeout = 1000, ...props }) => {
const $inputValue = useBoundLink( $value )
.onChange(
useThrottle(
x => $value.set( x ),
timeout,
[ $value.value ]
)
);
return <input {...$inputValue.props} {...props}/>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment