From d87170416393c4f01d16601b90a6649398c9bdff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Collin=20L=C3=B8kken?= Date: Mon, 8 Jan 2024 14:28:52 +0100 Subject: [PATCH] refactor: unpack getValues --- .../dm-core-plugins/src/form/components/PrimitiveArray.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/dm-core-plugins/src/form/components/PrimitiveArray.tsx b/packages/dm-core-plugins/src/form/components/PrimitiveArray.tsx index 198fc9997..b25cedd5a 100644 --- a/packages/dm-core-plugins/src/form/components/PrimitiveArray.tsx +++ b/packages/dm-core-plugins/src/form/components/PrimitiveArray.tsx @@ -36,10 +36,10 @@ const PrimitiveArray = ({ onChange, }: PrimitiveArrayProps) => { const [hovering, setHovering] = useState(-1) - const methods = useFormContext() + const { getValues } = useFormContext() const updateValues = (index: number, newValue: TPrimitive): void => { - const newValues = [...methods.getValues(namePath)] + const newValues = [...getValues(namePath)] switch (attribute.attributeType) { case 'boolean': newValues[index] = newValue @@ -55,7 +55,7 @@ const PrimitiveArray = ({ } } const removeItem = (index: number) => { - const newValues = [...methods.getValues(namePath)] + const newValues = [...getValues(namePath)] newValues.splice(index, 1) onChange(newValues) }