Skip to content

useEventListener

Read as Markdown

import { useEventListener, Group, type PibblNode } from "@pibbl/core";

useEventListener(handlers) accepts PibblEventHandlers, is render-only, and updates propagation listeners for the current component identity. It does not define hit geometry; combine it with a primitive target or useEventTarget. Pibbl owns the listener registration and releases it on replacement or component teardown.

function Panel({ children }: { children: PibblNode }) {
useEventListener({ onClickCapture: (event) => console.log(event.type) });
return <Group>{children}</Group>;
}

See the Propagation and cancellation live example.

Container children use PibblNode.

Registers the current component’s event handlers with mount-owned cleanup.

useEventListener: (handlers: PibblEventHandlers) => void

Related API: useEventListener, PibblEventHandlers.

  • handlers — Handlers to register for the current component’s event participation. See PibblEventHandlers .

PibblEventHandlers

View source — packages/core/src/lib/hooks/use-event-listener.ts:19

Read the Input, focus, and native HTML companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.

Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.