Skip to content

Commit e8d9e61

Browse files
tastybentoclaude
andcommitted
Fix React hooks ordering error after blueprint submission
Moved useMemo calls for `summary` and `voxels` above the early `if (success) return` in SubmitForm. Placing hooks after a conditional return violated the Rules of Hooks (React error #300), causing a blank page after a successful PR submission. Also filters BentoBox itself out of the ChipPicker in PresetEditor so it no longer appears as a selectable addon. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1baf7d9 commit e8d9e61

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/web/components/Submit.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,18 @@ function SubmitForm({
763763
}
764764
}
765765

766+
const summary: ParsedSummary | null = useMemo(
767+
() => (dropped ? summarizeBlueprint(dropped.json) : null),
768+
[dropped],
769+
);
770+
771+
/* Real voxels for the live card preview. Computed once per file
772+
* so re-renders from typing don't re-walk the parsed JSON. */
773+
const voxels: RealVoxel[] = useMemo(
774+
() => (dropped ? deriveVoxels(dropped.json.blocks) : []),
775+
[dropped],
776+
);
777+
766778
if (success) {
767779
return (
768780
<SuccessState
@@ -781,18 +793,6 @@ function SubmitForm({
781793
);
782794
}
783795

784-
const summary: ParsedSummary | null = useMemo(
785-
() => (dropped ? summarizeBlueprint(dropped.json) : null),
786-
[dropped],
787-
);
788-
789-
/* Real voxels for the live card preview. Computed once per file
790-
* so re-renders from typing don't re-walk the parsed JSON. */
791-
const voxels: RealVoxel[] = useMemo(
792-
() => (dropped ? deriveVoxels(dropped.json.blocks) : []),
793-
[dropped],
794-
);
795-
796796
const gameModeLower = gameMode ? gameMode.toLowerCase() : 'gamemode';
797797
const slugForPath = name || 'slug';
798798

src/web/components/admin/PresetEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function ChipPicker({
158158
selected: string[];
159159
onToggle: (name: string) => void;
160160
}) {
161-
const sorted = [...addons].sort((a, b) => {
161+
const sorted = [...addons].filter((a) => a.name.toLowerCase() !== 'bentobox').sort((a, b) => {
162162
if (a.gamemode !== b.gamemode) return a.gamemode ? -1 : 1;
163163
return a.name.localeCompare(b.name);
164164
});

0 commit comments

Comments
 (0)