feat: add use-arrow-clusters react hook package - #8
Conversation
|
@aysead Great start, left some feedback on the memo deps and types — let me know what you think |
|
Hi @StoneTapeStudios,
|
|
Hi @StoneTapeStudios, I've just pushed the missing package.json and pnpm-lock.yaml files so the CI can find the test dependencies. It looks like the GitHub Actions workflow is waiting for a maintainer's approval to run ('Action required'). Could you please approve the workflow run when you have a chance? Thanks again for all the guidance. |
There was a problem hiding this comment.
@aysead Nice work on this iteration — the hook structure is clean and the dependency array improvements from the last round are solid. Left another round of feedback, mostly around tightening up the tests and a few small consistency items.
The main ones:
- The test mock should return a proper ClusterOutput shape instead of [] — the other packages' tests have a makeOutput() pattern worth following here
- Missing a memoization stability test (verifying the engine isn't re-created when only bounds/zoom change), which is the core thing this hook is supposed to guarantee
- A few small housekeeping items: missing test script, quote consistency
Also left a note on the useMemo + engine.load() tradeoff — not a blocker, just something to be aware of given how heavy load() is compared to the vanilla Supercluster equivalent.
Let me know if any of the comments need clarification.
docs(use-arrow-clusters): update wording and add filterMask warning
|
I've just pushed the final updates: Updated the test mock to return a proper ClusterOutput shape using a makeOutput() helper. Added the missing memoization stability test to verify the engine isn't re-created unnecessarily. Refactored the hook to use the useRef manual memoization pattern for safer engine stability, as you suggested. Fixed the minor housekeeping items (test script in package.json, quote consistency, and the README wording). Ready for your review. |
|
Hey @aysead , Everything looks great! Thanks so much for your work on this. Eventually it'd be nice if we had a React example in the examples folder. I'd be interested to see/hear how you're using the package. All the best 🙏 |
Hi @StoneTapeStudios,
As discussed, I've created the initial structure for the
use-arrow-clustershook as a separate package to keep the core framework-agnostic.What's included in this draft:
Scaffolded a new "use-arrow-clusters" package within the monorepo ("package.json", "tsdown", "tsconfig").
Implemented the "useArrowClusters" hook with the dual "useMemo" approach we talked about:
Next steps to discuss:
Before I add tests and update the README with the usage examples (and the note about Arrow Table reference stability), I wanted to get your feedback on this initial structure and the hook's API signature.
Let me know if this direction looks good to you!