MCPcopy Create free account
hub / github.com/UI5/webcomponents / createReactComponent

Function createReactComponent

packages/base/src/createReactComponent.ts:29–55  ·  view source on GitHub ↗
(klass: T)

Source from the content-addressed store, hash-verified

27 * const ReactButton = createReactComponent(Button);
28 */
29export default function createReactComponent<T extends typeof UI5Element>(klass: T) {
30 const tag = klass.getMetadata().getTag();
31
32 return function Component(props: InstanceType<T>["_jsxProps"]) {
33 const patchedProps: Record<string, unknown> = {};
34
35 Object.entries(props as Record<string, unknown>).forEach(([key, value]) => {
36 if (key.startsWith("on") && typeof value === "function") {
37 // React 19 wraps DOM events (change, click, input, etc.) in SyntheticEvent,
38 // hiding CustomEvent.detail under nativeEvent.detail.
39 // Patch all event handlers to restore detail from nativeEvent.
40 const originalHandler = value;
41 patchedProps[key] = (e: Event) => {
42 const nativeDetail = (e as unknown as { nativeEvent?: { detail: unknown } }).nativeEvent?.detail;
43 if (nativeDetail !== undefined) {
44 (e as unknown as { detail: unknown }).detail = nativeDetail;
45 }
46 originalHandler(e);
47 };
48 } else {
49 patchedProps[key] = value;
50 }
51 });
52
53 return createElement(tag, patchedProps);
54 };
55}

Callers

nothing calls this directly

Calls 2

getTagMethod · 0.80
getMetadataMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…