slickgrid-react
Version:
Slickgrid components made available in React
18 lines • 927 B
JavaScript
import React, { createRef } from 'react';
import { createRoot } from 'react-dom/client';
// these 2 functions are the same except that 1 is synch and the promise is delayed by a CPU cycle before resolving
export function createReactComponentDynamically(customComponent, targetElm, props, root) {
const compRef = createRef();
root ??= createRoot(targetElm);
root.render(React.createElement(customComponent, { ...props, ref: compRef }));
return { component: compRef.current, root: root };
}
export function loadReactComponentDynamically(customComponent, targetElm, props, root) {
return new Promise((resolve) => {
const compRef = createRef();
root ??= createRoot(targetElm);
root.render(React.createElement(customComponent, { ...props, ref: compRef }));
queueMicrotask(() => resolve({ component: compRef.current, root: root }));
});
}
//# sourceMappingURL=reactUtils.js.map