- Shipped
- September 6, 2026 at 10:58 PM UTC
- Author
- Kamo
- Commit
- f3939a8
Clicking a thumbnail threw "Minified React error #310 — rendered more hooks than during the previous render" over the whole page. Mine, from the attachment-auth fix. `AttachmentLightbox` returns early when the lightbox is closed, and I put `useAttachmentSource` AFTER that guard: the closed render ran three hooks and the open render ran four. A hook cannot live after a conditional return, so the part that needs one is now a child mounted only when there is something to show. That child is keyed by the attachment id, which fixes a second bug in the same lines. `failure` and the one-shot cookie re-plant are state inside the hook and do not reset when its URL changes, so arrowing from a broken attachment to a good one would have kept showing the failure. A key per attachment mounts a fresh verdict. It shipped because every existing test rendered this component closed, or not at all — the closed→open transition is the one that breaks. The new test asserts exactly that transition, and against the previous commit it reproduces both halves: "Rendered more hooks than during the previous render" on open, and "Rendered fewer hooks than expected" on close.