Skip to content

Commit

Permalink
Refactor nest functions
Browse files Browse the repository at this point in the history
  • Loading branch information
danetsao committed Feb 21, 2024
1 parent 327b743 commit da5f505
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/components/Criteria/CriteriaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ export default function CriteriaCard({
format: (value) => value ?? CriteriaTerminalType.PASS,
}).input.value;

const cardInterior = useMemo(() => {
const noneOfReturnType = (
<FieldArray name={`${name}.criteria`}>
{({ fields }) => fields.map((innerName, index) => (
<CriteriaCard
key={innerName}
name={innerName}
alone={fields.length === 1}
onRemove={() => fields.remove(index)}
/>
))
}
</FieldArray>
);
const noneOfReturnType = useMemo(() => (
<FieldArray name={`${name}.criteria`}>
{({ fields }) => fields.map((innerName, index) => (
<CriteriaCard
key={innerName}
name={innerName}
alone={fields.length === 1}
onRemove={() => fields.remove(index)}
/>
))
}
</FieldArray>
), [name]);

const cardInterior = useMemo(() => {
switch (type) {
case CriteriaTerminalType.PASS:
return <div />;
Expand Down Expand Up @@ -103,7 +103,7 @@ export default function CriteriaCard({
default:
return <Loading />;
}
}, [name, type]);
}, [name, noneOfReturnType, type]);

return (
<Card
Expand Down

0 comments on commit da5f505

Please sign in to comment.