blinkdb-js / blinkdb

🗃️ An in-memory JS database optimized for large scale storage on the frontend.
https://blinkdb.io
MIT License
119 stars 10 forks source link

fix: hooks cause infinite rerender #31

Closed Boffee closed 1 year ago

Boffee commented 1 year ago

the react blinkdb hooks causes there callers to rerender infinitely because the useEffect in useMany watches the query argument, which is a new object instance every time the caller rerenders.

A simple solution is to stringify the query in useEffect.

netlify[bot] commented 1 year ago

Deploy Preview for blinkdb canceled.

Name Link
Latest commit 821a44bdc5142869a6592572d093c0abccf20820
Latest deploy log https://app.netlify.com/sites/blinkdb/deploys/6532f2e3560e43000832c241
codecov[bot] commented 1 year ago

Codecov Report

Merging #31 (821a44b) into main (6658a7d) will decrease coverage by 0.01%. Report is 5 commits behind head on main. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #31      +/-   ##
==========================================
- Coverage   95.15%   95.14%   -0.01%     
==========================================
  Files          74       74              
  Lines        1136     1134       -2     
  Branches      263      262       -1     
==========================================
- Hits         1081     1079       -2     
  Misses         55       55              
Files Coverage Δ
packages/db/src/core/remove.ts 88.88% <100.00%> (ø)
packages/db/src/core/removeMany.ts 100.00% <100.00%> (ø)
packages/react/src/retrieval/useMany.ts 100.00% <ø> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

maradotwebp commented 1 year ago

Thanks for the fix!