frontend-app-api: store bootstrap errors for app root

Route bootstrap finalization failures through an external store that re-enters React at app/root.children, and simplify prepared app finalization to use a success-only callback.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-03-16 01:32:29 +01:00
parent 12f809015f
commit 89fd91eaf8
4 changed files with 65 additions and 105 deletions
@@ -291,9 +291,6 @@ describe('createApp', () => {
triggerSignInSuccess(identityApi);
});
await expect(
screen.findByText(/Error in app/),
).resolves.toBeInTheDocument();
await expect(
screen.findByText('sign-in bootstrap failed'),
).resolves.toBeInTheDocument();
+1 -11
View File
@@ -152,22 +152,12 @@ function PreparedAppRoot(props: {
const [finalizedApp, setFinalizedApp] = useState<
FinalizedSpecializedApp | undefined
>();
const [bootstrapError, setBootstrapError] = useState<Error | undefined>();
useEffect(
() => props.preparedApp.onFinalized(setFinalizedApp, setBootstrapError),
() => props.preparedApp.onFinalized(setFinalizedApp),
[props.preparedApp],
);
if (bootstrapError) {
return (
<>
<div>{bootstrapError.message}</div>
<h1>Error in app</h1>
</>
);
}
if (!finalizedApp) {
return bootstrapApp.element;
}