Skip to content

Commit 5c1f571

Browse files
committed
test(components): read the element:button renderer once at module scope
Creating the component reference during ParamHost's render tripped react-hooks/static-components in Lint UI. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jUba5gmu4hkimKCSC6
1 parent 47f9d6d commit 5c1f571

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎ui/packages/components/src/__tests__/element-button-paramDialogDescription-29249.test.tsx‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ const DESCRIPTION = {
5757
'zh-CN': '我们会向对方发送一封邀请邮件。',
5858
};
5959

60+
/**
61+
* The registered renderer, read once at module scope (a component created
62+
* during render remounts on every render). An unregistered `element:button`
63+
* fails the whole file here, before any row runs.
64+
*/
65+
function registeredElementButton() {
66+
const C = ComponentRegistry.get('element:button');
67+
if (!C) throw new Error('element:button not registered');
68+
return C;
69+
}
70+
const ElementButton = registeredElementButton();
71+
6072
/**
6173
* The param-collection host: opens a dialog from what the runner hands it and
6274
* leaves the promise pending, as a dialog awaiting its Confirm does.
@@ -76,11 +88,9 @@ function ParamHost({ action }: { action: Record<string, unknown> }) {
7688
});
7789
return new Promise(() => {});
7890
}, []);
79-
const C = ComponentRegistry.get('element:button');
80-
if (!C) throw new Error('element:button not registered');
8191
return (
8292
<ActionProvider handlers={{ api }} onParamCollection={onParamCollection}>
83-
<C
93+
<ElementButton
8494
schema={{
8595
type: 'element:button',
8696
properties: { label: { en: 'Invite member', 'zh-CN': '邀请成员' }, action },

0 commit comments

Comments
 (0)