Skip to content

Commit

Permalink
Do not use useMemo as is not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
anagperal committed Aug 2, 2024
1 parent db8eab9 commit d98308b
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions src/webapp/components/form/FieldWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useMemo } from "react";
import React, { useCallback } from "react";

import { TextInput } from "../text-input/TextInput";
import { UserSelector } from "../user-selector/UserSelector";
Expand Down Expand Up @@ -26,28 +26,16 @@ export const FieldWidget: React.FC<FieldWidgetProps> = React.memo((props): JSX.E
[field, onChange]
);

const commonProps = useMemo(
() => ({
id: field.id,
label: field.label,
onChange: handleChange,
helperText: field.helperText,
errorText: field.errors ? field.errors.join("\n") : "",
error: field.errors && field.errors.length > 0,
required: field.required && field.showIsRequired,
disabled: disabled,
}),
[
disabled,
field.errors,
field.helperText,
field.id,
field.label,
field.required,
field.showIsRequired,
handleChange,
]
);
const commonProps = {
id: field.id,
label: field.label,
onChange: handleChange,
helperText: field.helperText,
errorText: field.errors ? field.errors.join("\n") : "",
error: field.errors && field.errors.length > 0,
required: field.required && field.showIsRequired,
disabled: disabled,
};

switch (field.type) {
case "select": {
Expand Down

0 comments on commit d98308b

Please sign in to comment.