Skip to content

@serenity-is/domwise / Component

Class: Component<T>

Defined in: src/component.ts:21

Base class for class-based JSX components.

Extend this class and override render to return a JSXElement. Props (including optional children and ref) are available via props.

Example

class Greeting extends Component<{ name: string }> {
  render() {
    return <div>Hello, {this.props.name}!</div>;
  }
}
// usage: <Greeting name="World" />

Type Parameters

T

T = any

The type of the component's props (excluding children and ref which are added automatically).

Constructors

Constructor

new Component<T>(props): Component<T>

Defined in: src/component.ts:32

Creates a component instance.

Parameters

props

T & object

Props passed to the component, including optional children and ref.

Returns

Component<T>

Properties

props

readonly props: T & object

Defined in: src/component.ts:37

Props passed to this component instance, including optional children and ref.

Type Declaration

children?

optional children: ComponentChildren

ref?

optional ref: Ref<any>


isComponent

static isComponent: boolean = true

Defined in: src/component.ts:26

Marker used by the JSX factory to distinguish class components from function components. Do not modify.

Methods

render()

render(): JSXElement | null

Defined in: src/component.ts:44

Renders the component's output. Override in subclasses to return a DOM node, fragment, or null.

Returns

JSXElement | null

The rendered JSXElement, or null to render nothing.