Skip to content

Commit

Permalink
Destructure the params used for useMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Dec 6, 2024
1 parent 4adfed1 commit da52b0b
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions packages/response-ops/rule_form/src/rule_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,46 @@ export interface RuleFormProps {
}

export const RuleForm = (props: RuleFormProps) => {
const { plugins, onCancel, onSubmit } = props;
const { plugins: _plugins, onCancel, onSubmit } = props;
const { id, ruleTypeId } = useParams<{
id?: string;
ruleTypeId?: string;
}>();

const {
http,
i18n,
theme,
userProfile,
application,
notifications,
charts,
settings,
data,
dataViews,
unifiedSearch,
docLinks,
ruleTypeRegistry,
actionTypeRegistry,
} = _plugins;

const ruleFormComponent = useMemo(() => {
const plugins = {
http,
i18n,
theme,
userProfile,
application,
notifications,
charts,
settings,
data,
dataViews,
unifiedSearch,
docLinks,
ruleTypeRegistry,
actionTypeRegistry,
};
if (id) {
return <EditRuleForm id={id} plugins={plugins} onCancel={onCancel} onSubmit={onSubmit} />;
}
Expand All @@ -60,7 +93,26 @@ export const RuleForm = (props: RuleFormProps) => {
}
/>
);
}, [id, ruleTypeId, plugins, onCancel, onSubmit]);
}, [
http,
i18n,
theme,
userProfile,
application,
notifications,
charts,
settings,
data,
dataViews,
unifiedSearch,
docLinks,
ruleTypeRegistry,
actionTypeRegistry,
id,
ruleTypeId,
onCancel,
onSubmit,
]);

return <QueryClientProvider client={queryClient}>{ruleFormComponent}</QueryClientProvider>;
};

0 comments on commit da52b0b

Please sign in to comment.