Index of every page on this site: llms.txt
All skills
gmi-software avatar

/react-native-better-clustering

@443959a
Run it yourself

Expert guide to react-native-better-clustering — a drop-in clustered MapView for react-native-maps backed by a C++ supercluster engine over Nitro/JSI. Use when installing, configuring, or debugging it; when clustering is slow, wrong, or flickering; when handling thousands of map markers; when migrating from react-native-map-clustering or react-native-clusterer; and when changing the library's TypeScript, C++, or Nitro specs. Also use before writing any performance claim about map clustering, pan, zoom, or marker frame rate.

  • 11 files
  • 102.9 KB
  • MIT
  • Updated 3 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/gmi-software/better-skills/react-native-better-clustering

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈141 tokens for metadata: the name and description. ≈1.8k when used: this file. ≈24k more on demand in 10 files.

Description uses 7.0% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈562 characters, or 7.0%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

react-native-better-clustering

Drop-in clustered MapView for react-native-maps. Clusters are computed in C++ via a Nitro HybridObject; every visible bubble/leaf is still a React react-native-maps <Marker>.

Source is truth. Where the library README and the code disagree, follow the code.

Paths like package/src/... are relative to a library checkout, not this skills repo.

Version verification

Package:            react-native-better-clustering
Version:            1.0.0
Commit:             7c7d659046a3d1bb8b7d4cb06a94f6e0d509862e
Verification date:  2026-08-21
npm view react-native-better-clustering version
node -p "require('react-native-better-clustering/package.json').version"

If your version differs, re-read node_modules/react-native-better-clustering/src/ before trusting internals.

When to use

  • Installing / configuring clustering on a React Native map
  • Migrating from react-native-map-clustering or react-native-clusterer
  • Thousands of markers, pan/zoom jank, flicker, wrong membership
  • Native crash or Nitro load failure involving this package
  • Aggregating cluster values (clusterProperties)
  • Changing the C++ engine, Nitro spec, or React layer
  • Reviewing any performance claim about clustering / marker FPS

When NOT to use

Situation Instead
Base map / tiles / camera / gestures Load the react-native-maps skill
react-native-better-maps Load that skill — different library, native clustering
Mapbox / MapLibre / @rnmapbox/maps Those SDKs cluster internally
Non-geographic clustering This engine is lon/lat Web Mercator only

Core architecture

  1. Compute is C++; drawing is React. ClusterEngineCore builds the hierarchy; the default MapView mounts one RN Maps <Marker> per visible node.
  2. One HybridObject, not a map view. Nitro autolinks ClusterEngine → HybridClusterEngine.
  3. Load copies; query converts. packPoints → setPoints memcpy → sync getClusters that allocates one JS object per node.
  4. Rebuilds are all-or-nothing. No incremental insert API; data identity change destroys and rebuilds.
  5. Region sync is throttled (clusterUpdateIntervalMs default 100).

Details: architecture.md.

Thread safety (CRITICAL)

ClusterEngineCore is NOT thread-safe.
No mutex / lock / atomic protects build state.

Do not issue concurrent buildAsync / getClusters / getChildren / getLeaves / isBuilt
against the same engine instance.

Supercluster lifecycle gating is incidental protection only.
createClusterEngine() (headless) provides no such guarantee.

buildAsync moves work off the JS thread — that is not concurrent-query safety. For continuous querying during a rebuild, build a second engine fully, then swap. → architecture.md

API guidance

Import Surface
react-native-better-clustering Drop-in clustered MapView
.../hooks useClusterer — you own the MapView
.../engine Supercluster, createClusterEngine — headless
.../geojson Feature helpers
.../utils packPoints, etc.
.../clusterer Clusterer component

clusterProperties is NOT a root MapView prop. Aggregation exists only on /engine and /hooks (sum | min | max only). Surface: api.md. Deep detail: aggregation.md.

Problem → reference routing

Problem Start here
Concurrent engine / headless threading architecture.md
Installation & setup setup.md
Blank Android map setup.md
Basic usage / which API api.md
Slow / "make it 2× faster" Canonical optimization → performance.md
10k+ markers / ~20 FPS pan performance.md
Marker re-renders / flicker rendering.md
Wrong membership / viewport edge algo.md
Aggregation (clusterProperties) aggregation.md + api.md
Migration migration.md
Regression / PR slower performance.md
Debugging unknown debugging.md
Platform iOS / Android setup.md, debugging.md
Testing / contributing contributing.md

Canonical optimization workflow

1. Establish baseline
2. Define workload
3. Profile
4. Identify bottleneck
5. Form hypothesis
6. Smallest change
7. Benchmark
8. Compare before vs after
9. Add regression coverage

Vague "2× faster" → reframe first: point count, distribution, pan/zoom/load, platform, device, debug vs release, metric, current baseline. Profiling: performance.md.

Do not rewrite the KD-tree without a profile, add memoization that does not stabilize identity, or claim FPS without measuring release builds on a real device.

Common mistakes

  • Treating clustering FPS as engine FPS — visible RN Maps markers are usually the ceiling
  • Concurrent buildAsync + query on one headless engine
  • Passing clusterProperties to root MapView
  • Claiming "zero-copy" / "60 FPS at 10k" — not supported by source
  • Optimising without a baseline workload
  • Assuming Jest covers C++ clustering (it mocks Nitro)

Troubleshooting

  1. Name the layer: compute / JSI / React commit / RN Maps annotations → performance.md
  2. Name the trigger: dataset identity, region event, settle, mount
  3. Measure on the failing platform → performance.md
  4. Then fix → debugging.md

Decision tree and real error strings live in the debugging reference.

Known limitations

Limitation Consequence
Rendering is RN Maps markers Visible count, not point count, sets FPS ceiling
ClusterEngineCore not thread-safe Serialize build/query per instance
No incremental updates data identity change rebuilds everything
clusterProperties not on root MapView Use /hooks or /engine
New Architecture + no Expo Go RN 0.78+; needs a development build
No CI performance gate Regressions need your own measurement

Accuracy

Label claims SOURCE FACT / TEST FACT / BENCHMARK FACT / EXAMPLE FACT / INFERENCE. Banned as fact: "zero-copy", "zero-bridge", "no JS overhead", "10k markers at 60 FPS".

2D KD-tree range/within complexity is typically O(√n + k) (not O(log n + k)). Build walks current in array/ingest order; the tree answers neighbour queries only.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 443959a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 3 months ago
Other metadata
metadata
{
  "package": "react-native-better-clustering",
  "version": "1.0.0",
  "commit": "7c7d659046a3d1bb8b7d4cb06a94f6e0d509862e",
  "verified": "2026-08-21",
  "repository": "https://github.com/gmi-software/react-native-better-clustering",
  "audience": "library users and library contributors",
  "tags": "react-native, clustering, maps, markers, geospatial, supercluster, nitro, jsi, cpp, performance, ios, android, expo"
}

README badge

README badge for gmi-software/better-skills/react-native-better-clustering