-
Notifications
You must be signed in to change notification settings - Fork 208
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
(feat) Adding useDebounce to the react utils #756
Conversation
Size Change: -620 kB (-18%) 👏 Total Size: 2.81 MB
ℹ️ View Unchanged
|
You'll need to add the export to Please add this to the esm-framework mocks as well. You can just do Please don't just check all the boxes in the PR description. Only check them if they're both relevant and done. Styleguide: irrelevant. Tests: not done but optional for a hook this simple. Mock: required, not done. |
Applied suggestions. You still need to add to public.ts. |
I thought I did. Pushing it now |
…into use-debounce
I did the changes but just had it locally only 🤦 Please re-review |
Requirements
For changes to apps
If applicable
Summary
We use SWR everywhere to fetch information and control the number of requests, especially for searching. We also use lodash in many places for this, which is fine. However, one downside is that the search component is no longer a controlled input. This is because the state set by the search input will be set after a delay, and if that same state is passed to the search box, it will not work correctly in the UI. In some cases, having an uncontrolled input is acceptable, but in cases where there is an external "Clear results" button that clears the search input, it becomes tedious to handle.
Instead of all these workarounds for a single use case, why not have a hook that handles debouncing for us without requiring an uncontrolled input?
For a similar example, you can refer: openmrs/openmrs-esm-patient-chart#1322
Example
Related Issue
Other