Files
clean-architecture-frontend…/src/bootstrap/main.jsx
T

53 lines
1.3 KiB
React

import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { BootConfigError, loadRuntimeConfig } from "./load-runtime-config.js";
/** @param {{ environment: string }} props */
function BootstrapShell({ environment }) {
return (
<main>
<h1>Clean Architecture Frontend</h1>
<p>{environment} 런타임 계약이 검증되었습니다.</p>
</main>
);
}
/** @param {{ supportReference: string }} props */
function BootErrorShell({ supportReference }) {
return (
<main role="alert">
<h1>애플리케이션을 시작할 없습니다.</h1>
<p>지원 참조: {supportReference}</p>
</main>
);
}
const rootElement = document.getElementById("root");
if (!rootElement) {
throw new Error("Missing #root mount element");
}
const root = createRoot(rootElement);
async function boot() {
try {
const runtime = await loadRuntimeConfig();
root.render(
<StrictMode>
<BootstrapShell environment={runtime.config.APP_ENV} />
</StrictMode>,
);
} catch (error) {
const supportReference =
error instanceof BootConfigError
? error.safe.supportReference
: "boot:unknown";
root.render(<BootErrorShell supportReference={supportReference} />);
}
}
void boot();