Replies: 1 comment
-
With a coming version ( But there is no graceful fallback. But you could roll your own: // this is from our codebase. ComponentLibrary holds all our components and exposes a method to findComponentsById
// if the component cannot be found it throws an error (thus the try catch block)
// you can alter it to your needs an way you store your resolvers
export const findComponentsWithoutResolvers = (
nodes: SerializedNodes
): SerializedNode[] => {
return Object.entries(nodes)
.map(([key, node]) => {
try {
if (typeof node.type === 'string') {
ComponentLibrary.getInstance().findComponentById(node.type);
} else {
ComponentLibrary.getInstance().findComponentById(
node.type.resolvedName
);
}
return null;
} catch (e) {
return node;
}
})
.filter((node) => node !== null);
}; you can call it with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way of providing a fallback for nodes that are not listed in the resolver?
If a node's name doesn't match one of the resolvers, an error is thrown:
I'm thinking in the case when a change or rename in the resolver for a node, and this will cause all pages/documents that still reference to the old resolver will crash the editor.
In these cases a graceful fallback may help, at least for the developers to know what's going on (where the missing node's name may be displayed).
Beta Was this translation helpful? Give feedback.
All reactions