frontend-plugin-api: make all route refs optional at all times

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-08-06 10:44:30 +02:00
parent e46805cdd0
commit 72754db000
27 changed files with 172 additions and 318 deletions
@@ -189,18 +189,12 @@ function OutputLink(props: {
}) {
const routeRef = props.node?.instance?.getData(coreExtensionData.routeRef);
let link: string | undefined = undefined;
try {
// eslint-disable-next-line react-hooks/rules-of-hooks
link = useRouteRef(routeRef as RouteRef<undefined>)();
} catch {
/* ignore */
}
const link = useRouteRef(routeRef as RouteRef<undefined>);
return (
<Tooltip title={<Typography>{props.dataRef.id}</Typography>}>
<Box className={props.className}>
{link ? <Link to={link}>link</Link> : null}
{link ? <Link to={link()}>link</Link> : null}
</Box>
</Tooltip>
);