Performance regression from dom to hooks
See original GitHub issueš Bug description
I noticed that performance of updating the search query became quite a bit worse when I changed from -dom
to -web-hooks
.
Some functions that seem responsible for pretty much all of the wait time:
escapeHits
recursiveEscape
getWidgetRenderState
š Bug reproduction
Steps to reproduce the behavior:
- Set up a basic React-Instantsearch with
Hits
andSearchBox
withreact-instantsearch-dom
- Start typing, note the quick rendering
- Switch to
react-instantsearch-dom
- Start typing, note the slower rendering
Sorry for the lack of demo repo, my project is currently closed source. Iāll try to dive in deeper, Iāll update this issue
Some findings / thoughts:
- The issue scales with the amount of
HitsPerPage
- Even if my custom
Hit
component returns null, the issue is bad, so itās not really the rendering part, I think. - It may have something to do with my relatively large documents, which contains many keys (about 100 KV combos)
Live reproduction:
https://codesandbox.io/s/github/algolia/react-instantsearch/tree/master/examples/hooks
Environment
- React InstantSearch Hooks version: 6.38.0
- React version: 18.2.0
- Browser: Firefox 108
- OS: MacOS
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Detecting when React Components are Visually Rendered as ...
In this tip, I'll demonstrate a simple React Hook for determining when your React Component has presented itself visually to the user viaĀ ......
Read more >React Hooks to optimize performance | by Gerardo FernƔndez
In this article and taking advantage of the consolidation of the React Hooks I want to present a couple of solutions that can...
Read more >Testing the React Router useNavigate Hook ... - LogRocket Blog
You can use the useNavigate Hook to navigate to other pages, as seen in the code block below: import { useNavigate } from...
Read more >React Virtual Dom and Memo on Performance - Medium
I will explain the Virtual Dom concepts, Memo, useMemo hook in detail including,. What they are? How they are gaining performance?
Read more >React hooks: call component as function vs render as element
Here are some implications of calling component as function vs rendering it as element. Potential violation of rules of hooks.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Haroenv
No multiple components, but I do have a
useHits
somewhere else to render the count.Let me try this:
escapeHTML can be avoided in React, because you donāt render dangerouslySetInnerHTML, therefore it can be faster if you do this:
https://codesandbox.io/s/silly-fermi-qj4dbn?file=/App.tsx:4270-4410
Iāll think about how this can be improved and leads to less wasted cycles by default too