Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function ImportedComponent(props: ComponentOptions): ReactElement | null {
const {loading, error, loadable, imported: Component, retry} = useImported(props.loadable);
if (loading && props.async) {
throw loadable.resolution;
}
if ('render' in props && props.render) {
return props.render(Component, {loading, error}, props.forwardProps)
}
if (Component) {
// importedUUID for cache busting
return
}
if (loading) {
if (props.async) {
throw loadable.resolution;
}
return props.LoadingComponent
?
: null;
}
if (error) {
// always report about errors
console.error('react-imported-component', error);
// let's rethrow the error after react leaves this function
// this might be very crucial for the "safe" dev mode
{items.map(({ prop, type, required, defaultProp, description }, id) => (
{prop && <code>{prop}</code>}
{type && <code>{type}</code>}
{required && <>✔️}
{defaultProp && <code>{defaultProp}</code>}
{description && <>{description}}
))}
{items.map(item => {
const { label, ...other } = item;
return (
{label}
);
})}
function renderChildren(
node,
authListKey,
mouseIsOverNav,
getListByKey,
adminPath,
depth,
onRenderIndexPage
) {
if (node.children) {
const groupKey = uid(node.children);
depth += 1;
return (
{node.label && {node.label}}
{node.children.map(child =>
renderChildren(
child,
authListKey,
mouseIsOverNav,
getListByKey,
adminPath,
depth,
onRenderIndexPage
)
)}
{social.map(({ label, href }) => (
{label}
))}