Commit 0b7ad7f
Fix infinite update loop crashing the map (React error #185) (#34)
MediaMarkers.tsx was passing an inline arrow function as markerRef,
giving it a new identity on every render. useClusterer relies on ref
callback identity staying stable per marker (documented in its own
comment) - a fresh function each render makes React detach/reattach
every AdvancedMarker's ref on every render, which triggers the
setMarkers state update in a loop and blows past React's max update
depth, crashing the whole page with any geotagged media on the map.
Fixed by caching one stable ref-callback function per post id (same
pattern useClusterer itself uses internally), reading the post to tag
onto the marker from a ref instead of capturing it in a new closure.
Verified: npm run build, npm run lint.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>1 parent e474251 commit 0b7ad7f
1 file changed
Lines changed: 30 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
17 | 45 | | |
18 | 46 | | |
19 | 47 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 48 | + | |
32 | 49 | | |
33 | 50 | | |
34 | 51 | | |
| |||
0 commit comments