react-code-canvas
Version:
A browser-based canvas for rendering React components at runtime
24 lines (23 loc) • 1.05 kB
TypeScript
import { Component, ReactElement } from 'react';
import { RunnerOptions, Scope } from './types';
export type RunnerProps = RunnerOptions & {
/** callback on code be rendered, returns error message when code is invalid.
* `hasElement` reports whether real (non-null) content was produced. */
onRendered?: (error?: Error, hasElement?: boolean) => void;
};
type RunnerState = {
element: ReactElement | null;
error: Error | null;
prevCode: string | null;
prevScope: Scope | undefined;
};
export declare class Runner extends Component<RunnerProps, RunnerState> {
state: RunnerState;
static getDerivedStateFromProps(props: RunnerProps, state: RunnerState): Partial<RunnerState> | null;
static getDerivedStateFromError(error: Error): Partial<RunnerState>;
componentDidMount(): void;
shouldComponentUpdate(nextProps: RunnerProps, nextState: RunnerState): boolean;
componentDidUpdate(): void;
render(): ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
}
export {};