-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Open
Labels
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- p5.strands
- WebGL
- DevOps, Build process, Unit testing
- Internationalization (i18n)
- Friendly Errors
- Other (specify if possible)
p5.js version
N/A - website repo issue, not p5.js core
Web browser and version
All browsers
Operating system
all
Issue :
Every time searchTerm changes, SearchProvider:
- fetches the entire search index JSON again
- flattens it
- creates a brand new Fuse instance
- runs the search
Typing "createVector" = 13 requests to the same en.json. No debounce,
no abort, no caching. The Fuse index is expensive to build and should
be created once per locale, not per keystroke.
There's also a race condition, no AbortController means a slow response
for "col" can resolve after "color" and overwrite the results.
Should be:
- fetch + build Fuse once per locale change, store in a ref
- separate effect just for running fuse.search(searchTerm)
- debounce the search (~250ms)
- AbortController on the fetch with cleanup
Easy to reproduce: open /search/, DevTools Network tab, type anything
fast and watch duplicate requests pile up.
File: src/components/SearchProvider/index.tsx
Reactions are currently unavailable