Skip to content

Commit

Permalink
fixes render bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee committed Feb 22, 2021
1 parent 6409d6b commit df0f999
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const MitreAttackSubtechniqueFields: React.FC<AddSubtechniqueProps> = ({
const values = field.value as Threats;

const technique = useMemo(() => {
return values[threatIndex].technique ?? [];
return [...(values[threatIndex].technique ?? [])];
}, [values, threatIndex]);

const removeSubtechnique = useCallback(
Expand All @@ -65,10 +65,11 @@ export const MitreAttackSubtechniqueFields: React.FC<AddSubtechniqueProps> = ({
...technique[techniqueIndex],
subtechnique: subtechniques,
};
threats[threatIndex].technique = technique;
onFieldChange(threats);
}
},
[field, onFieldChange, techniqueIndex, technique]
[field, onFieldChange, techniqueIndex, technique, threatIndex]
);

const addMitreAttackSubtechnique = useCallback(() => {
Expand All @@ -87,9 +88,9 @@ export const MitreAttackSubtechniqueFields: React.FC<AddSubtechniqueProps> = ({
subtechnique: [{ id: 'none', name: 'none', reference: 'none' }],
};
}

threats[threatIndex].technique = technique;
onFieldChange(threats);
}, [field, onFieldChange, techniqueIndex, technique]);
}, [field, onFieldChange, techniqueIndex, technique, threatIndex]);

const updateSubtechnique = useCallback(
(index: number, value: string) => {
Expand Down

0 comments on commit df0f999

Please sign in to comment.