set-up-modus-event-listeners

Set up and clean up Modus web component event listeners in React.

3|2|Updated Oct 3, 2025
One-click install
npx skills add https://github.com/julianoczkowski/create-trimble-app --skill set-up-modus-event-listeners
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: set-up-modus-event-listeners
Source: https://github.com/julianoczkowski/create-trimble-app/tree/main/templates/react/.cursor/skills/set-up-modus-event-listeners
Command: npx skills add https://github.com/julianoczkowski/create-trimble-app --skill set-up-modus-event-listeners

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Streamline and standardize the setup and cleanup of Modus web component event listeners inside React components, reducing boilerplate and avoiding memory leaks.

Core Features & Use Cases

  • Null-checks the target Modus component reference before attaching listeners to prevent runtime errors.
  • Attaches listeners conditionally based on provided React props, enabling flexible event handling.
  • Ensures proper cleanup on unmount to prevent leaks and stale handlers.
  • Supports typed event handlers for strong TypeScript guarantees and easier maintenance.

Quick Start

Wrap a Modus web component in a React component and attach listeners using useEffect with a cleanup function.

Frequently Asked Questions about set-up-modus-event-listeners

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up event listeners for Modus web components in React?

To set up event listeners for Modus web components in React, wrap the component and attach listeners using the useEffect hook, syncing web component events directly to React state with typed handlers for strong TypeScript guarantees.

Why do my Modus web components cause memory leaks in React?

Modus web components cause memory leaks in React when event listeners are not properly removed. You can prevent leaks and stale handlers by returning a cleanup function inside useEffect to tear down listeners on component unmount.

Can I conditionally attach event listeners to web components in React?

Yes, you can conditionally attach event listeners to web components in React by checking if the specific handler prop is provided before binding, and by null-checking the component ref to ensure the target element exists.

What is the best way to handle multiple event types for a single web component in React?

The best way to handle multiple event types for a single web component in React is to group the listener attachments within a single useEffect hook, ensuring each event has a typed handler and a corresponding cleanup entry to prevent memory leaks.

Does this approach work with TypeScript for Modus web component events?

Yes, this approach works with TypeScript for Modus web component events by utilizing typed event handlers. This provides strong TypeScript guarantees, ensuring type safety and easier maintenance when syncing events to React state.