diff --git a/src/css/css.tsx b/src/css/css.tsx index 6ed5717b..fea79c62 100644 --- a/src/css/css.tsx +++ b/src/css/css.tsx @@ -697,8 +697,9 @@ export function SvgCss(props: XmlProps) { } export function SvgCssUri(props: UriProps) { - const { uri, onError = err, onLoad } = props; + const { uri, onError = err, onLoad, fallback } = props; const [xml, setXml] = useState(null); + const [isError, setIsError] = useState(false); useEffect(() => { uri ? fetchText(uri) @@ -706,9 +707,15 @@ export function SvgCssUri(props: UriProps) { setXml(data); onLoad?.(); }) - .catch(onError) + .catch((e) => { + onError(e); + setIsError(true); + }) : setXml(null); }, [onError, uri, onLoad]); + if (isError) { + return fallback ?? null; + } return ; }