Skip to content

Commit

Permalink
refactor: unpack getValues
Browse files Browse the repository at this point in the history
  • Loading branch information
collinlokken committed Jan 8, 2024
1 parent fbb56b3 commit d871704
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const PrimitiveArray = ({
onChange,
}: PrimitiveArrayProps) => {
const [hovering, setHovering] = useState<number>(-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
Expand All @@ -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)
}
Expand Down

0 comments on commit d871704

Please sign in to comment.