-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Change useState to useRef/useMemo for values not used for rende…
…ring (#678) This is the general rule for state vs. ref — only use state if it's rendered — which in the case of useLiveQuery is just the results. Changing e.g. the subscription key shouldn't cause a render. I noticed a lot of extra renders happening in my components with useLiveQuery which I traced to this problem. Without this PR, my component rendered 8 times, with it, it renders 2 times (starting the query and then showing results).
- Loading branch information
1 parent
d385d3c
commit fd8e901
Showing
1 changed file
with
23 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters