feat: migrate some hooks to usehooks-ts #2978
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
🤖 Generated by Copilot at cc1e8cd
This pull request replaces several custom or built-in React hooks with hooks from the
usehooks-ts
library in various components of the web app. This improves the performance, logic, and functionality of the components by avoiding unnecessary or erroneous effects on the initial render. It also simplifies the code and reduces code duplication. Theusehooks-ts
dependency is added to thepackage.json
file.Related issues
Fixes # (issue)
Type of change
Explanation of the changes
🤖 Generated by Copilot at cc1e8cd
useEffect
hook withuseUpdateEffect
hook fromusehooks-ts
library to avoid running callbacks on initial render and handle dependencies automatically (link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link)useIsMounted
hook withuseIsMounted
hook fromusehooks-ts
library to check mount status of components with a function instead of an object (link,link,link,link,link,link,link)useOnClickOutside
hook withuseOnClickOutside
hook fromusehooks-ts
library to handle click outside events with better compatibility and edge cases (link,link,link,link)useDebounce
hook withuseDebounce
hook fromusehooks-ts
library to debounce values with better performance and edge cases (link,link,link,link,link,link,link)useWindowSize
hook withuseWindowSize
hook fromusehooks-ts
library to get window size with better performance and edge cases (link,link)usehooks-ts
dependency topackage.json
file to use custom React hooks from this library (link)eslint-disable-next-line react-hooks/exhaustive-deps
comment fromuseEffect
hooks that are replaced byuseUpdateEffect
hooks, as they are no longer needed (link,link)ViewProfile
component for better code style and readability (link)alert
statement touseUpdateEffect
hook inAttachments
component, which is probably a debugging statement that should be removed before merging (link)Emoji
🪝🚀🧹