How to implement an ErrorHandle to wrap the handle error and loading of a resource?

I want to handle both the error and loading of a resource in the same component to wrap a page with this comonent so it renders a message error when there's one and loading when it's loading. Something like that but don't get the right sintax.

import { Component, Show, children} from "solid-js";
import Alert from "./Alert";

const ErrorHandle: Component = (props) => {
const c = children(() => props.children);
return (
<Show
when={!props.data.error}
fallback={
(props.data.error && <Alert severity="warning"> {props.data.error?.message}</Alert>) ||
"loading..."
}
>
{c}
</Show>
);
};

export default ErrorHandle;

import { Component, Show, children} from "solid-js";
import Alert from "./Alert";

const ErrorHandle: Component = (props) => {
const c = children(() => props.children);
return (
<Show
when={!props.data.error}
fallback={
(props.data.error && <Alert severity="warning"> {props.data.error?.message}</Alert>) ||
"loading..."
}
>
{c}
</Show>
);
};

export default ErrorHandle;
0 Replies
No replies yetBe the first to reply to this messageJoin