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:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user