readysite / example / index.ts
668 B
index.ts
// index.ts - Component bundle entry point
// Exports: render, unmount, and component exports

import * as React from 'react';
import * as ReactDOM from 'react-dom/client';

// Render function - mounts a component to an element
export function render(el: any, Component: React.ComponentType<any>, props: any) {
    const root = ReactDOM.createRoot(el);
    root.render(React.createElement(Component, props));
    el._root = root;
}

// Unmount function - unmounts a component from an element
export function unmount(el: any) {
    if (el._root) {
        el._root.unmount();
        delete el._root;
    }
}

// Export components
export * from './components/Counter';
← Back