Skip to content

Chore: Create useDebounce hook#4470

Merged
dnlsilva merged 6 commits into
developfrom
use-debounce
Sep 16, 2022
Merged

Chore: Create useDebounce hook#4470
dnlsilva merged 6 commits into
developfrom
use-debounce

Conversation

@dnlsilva

Copy link
Copy Markdown
Contributor

Proposed changes

Create useDebounce hook
Apply useDebounce hook where it is necessary

Issue(s)

How to test or reproduce

  • Test the DiscussionsView and CannedResponsesListView search filter.

Screenshots

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Comment thread app/lib/methods/helpers/debounce.ts Outdated
return _debounce;
}

export function useDebounce(func: Function, wait?: number, immediate?: boolean): (...args: any[]) => void {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this internally, but we should consider using a lib instead of creating our own.

My main concern is related to the useCallback usage and here's why https://github.com/xnimorz/use-debounce/blob/8020962aed8038c065f9468fd7cf1d9a1751ce62/src/useDebouncedCallback.ts#L150

return _debounce;
}

export function useDebounce(func: (...args: any) => any, wait?: number): (...args: any[]) => void {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, I think we can export useDebounce from libs/hooks, WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question here is more to maintain debounce things on the same local.
If we change the useDebounce to hooks, we will have two files doing the same thing.

@dnlsilva dnlsilva merged commit e146cba into develop Sep 16, 2022
@dnlsilva dnlsilva deleted the use-debounce branch September 16, 2022 15:19
diegolmello pushed a commit that referenced this pull request Sep 28, 2022
* create useDebounce hook

* fix types

* apply useDebounce hook

* migrate to use-debounce lib

* remove useless useDebounce
ivnxyz pushed a commit to NextiaDev/Rocket.Chat.ReactNative that referenced this pull request May 26, 2023
* create useDebounce hook

* fix types

* apply useDebounce hook

* migrate to use-debounce lib

* remove useless useDebounce
ivnxyz pushed a commit to NextiaDev/Rocket.Chat.ReactNative that referenced this pull request May 26, 2023
* create useDebounce hook

* fix types

* apply useDebounce hook

* migrate to use-debounce lib

* remove useless useDebounce
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.

3 participants