Skip to content

Commit ee7daa2

Browse files
committed
React is an extremely bad framework
1 parent cd48db9 commit ee7daa2

4 files changed

Lines changed: 31 additions & 47 deletions

File tree

build-www.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ const ctx = await esbuild.context(moduleConfig);
7272
console.log("Building standalone HTML...");
7373
buildStandalone();
7474

75+
if (process.argv.includes("--test-standalone")) {
76+
const template = readFileSync(join(outDir, "standalone.html"), "utf-8");
77+
const json = readFileSync("/tmp/ion.json");
78+
const formatted = template.replace(/\{\{\s*IONJSON\s*\}\}/, json);
79+
writeFileSync(join(outDir, "standalone-test.html"), formatted);
80+
}
81+
7582
if (process.argv.includes("--serve")) {
7683
await ctx.watch();
7784
const { hosts, port } = await ctx.serve({

package-lock.json

Lines changed: 17 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"@types/react-dom": "^18.3.1",
3232
"esbuild": "^0.25.8",
3333
"preact": "^10.27.2",
34+
"react": "^19.2.0",
35+
"react-dom": "^19.2.0",
3436
"typescript": "^5.9.2"
3537
}
36-
}
38+
}

www/main.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,14 @@ interface MenuBarProps {
3030
}
3131

3232
function MenuBar(props: MenuBarProps) {
33-
const [[ionjson, rawIonJSON], setIonJSON] = useState<readonly [IonJSON | null, string]>(
34-
props.ionjson
35-
? [props.ionjson, JSON.stringify(props.ionjson)]
36-
: [null, ""]
37-
);
33+
const [[ionjson, rawIonJSON], setIonJSON] = useState<readonly [IonJSON | null, string]>([null, ""]);
3834
const [funcIndex, setFuncIndex] = useState<number>(initialFuncIndex ?? 0);
3935

4036
// One-time initializer
4137
useEffect(() => {
42-
// Trigger funcSelected with any initial ion JSON
43-
if (ionjson) {
44-
props.funcSelected(ionjson.functions[funcIndex] ?? null);
38+
if (props.ionjson) {
39+
setIonJSON([props.ionjson, JSON.stringify(props.ionjson)]);
40+
props.funcSelected(props.ionjson.functions[funcIndex] ?? null);
4541
}
4642
}, []);
4743

0 commit comments

Comments
 (0)