UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

11 lines (10 loc) 541 B
import { jsx as _jsx } from "react/jsx-runtime"; import { Suspense, forwardRef } from 'react'; export function lazyifyComponent(key, ReactComponent) { const Component = forwardRef((props, ref) => (_jsx(Suspense, { fallback: null, children: _jsx(ReactComponent, { ...props, ref: ref }) }))); Component.displayName = key; return [key, Component]; } export function lazyMap(obj, prefix = '') { return Object.fromEntries(Object.entries(obj).map(([key, ReactComponent]) => lazyifyComponent(`${prefix}${key}`, ReactComponent))); }