Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(use-debounced-value): unable set and debounce value which is func… #9

Closed
wants to merge 1 commit into from
Closed

fix(use-debounced-value): unable set and debounce value which is func… #9

wants to merge 1 commit into from

Conversation

NWYLZW
Copy link

@NWYLZW NWYLZW commented Sep 15, 2023

If my target value type is function, it can't debounced which be used as state init function.

const func: ((a: boolean) => string) | undefined = useMemo(() => xxx, [])
const a = useDebouncedValue(func, 100)

And if I want to set state init value, it unable infer right type.

const a = useDebouncedValue(() => 1, 100)
// a type: () => number

But a real value is number.

@SukkaW
Copy link
Owner

SukkaW commented Sep 16, 2023

Close as won't merge.

You should never debounce a function as a value itself.

@SukkaW SukkaW closed this Sep 16, 2023
@NWYLZW NWYLZW deleted the fix/use-debounced-value/function-value-unable-set-and-debounce branch September 16, 2023 07:36
SukkaW added a commit that referenced this pull request Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants