nano-jsx
Version:
SSR first, lightweight 1kB JSX library.
58 lines (57 loc) • 1.78 kB
TypeScript
import { FC } from './core.js';
export declare class Component<P extends Object = any, S = any> {
props: P;
id: string;
private _elements;
private _skipUnmount;
private _hasUnmounted;
constructor(props: P);
static get isClass(): boolean;
get isClass(): boolean;
setState(state: S, shouldUpdate?: boolean): void;
set state(state: S);
get state(): S;
set initState(state: S);
/** Returns all currently rendered node elements */
get elements(): HTMLElement[];
set elements(elements: HTMLElement[]);
private _addNodeRemoveListener;
private _didMount;
private _willUpdate;
private _didUpdate;
private _didUnmount;
willMount(): any;
didMount(): any;
willUpdate(): any;
didUpdate(): any;
didUnmount(): any;
render(_update?: any): HTMLElement | void;
/** Will forceRender the component */
update(update?: any): void;
private _getHash;
}
/**
* Renders a class component and returns its reference.
*
* @param C Class Component
* @param props Properties
* @param children Children
* @param parent HTMLElement
* @returns Reference to Class Component
*
* @example
const componentReference = await renderComponentGetReference(
App, // Component
{ name: 'Joe' }, // Props
[Child, 'Some text', child], // Children (Component, string, FC)
parentElement // HTMLElement
)
componentReference.hello()
componentReference.setState({ age: 40 })
componentReference.update()
parentElement.remove()
*/
export declare function renderComponentGetReference<T extends Component>(C: {
new (props: any): T;
}, props: any, children: Array<typeof Component | FC | string>, parent: HTMLElement): Promise<T>;
//# sourceMappingURL=component.d.ts.map