index.ts

19 lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';

export function render(el: any, Component: React.ComponentType<any>, props: any) {
    const root = ReactDOM.createRoot(el);
    root.render(React.createElement(Component, props));
    (el as any)._root = root;
}

export function unmount(el: any) {
    if ((el as any)._root) {
        (el as any)._root.unmount();
        delete (el as any)._root;
    }
}

export { StatsWidget } from './components/StatsWidget';
export { DockerStatus } from './components/DockerStatus';
export { EnvEditor } from './components/EnvEditor';