mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-29 19:40:19 +03:00
don't mutate with lodash
This commit is contained in:
parent
ba3f3683d2
commit
4d9a9811c0
@ -6,7 +6,6 @@ import type {
|
|||||||
UiSchema,
|
UiSchema,
|
||||||
} from "@rjsf/utils";
|
} from "@rjsf/utils";
|
||||||
import { toFieldPathId } from "@rjsf/utils";
|
import { toFieldPathId } from "@rjsf/utils";
|
||||||
import { cloneDeep, set as lodashSet } from "lodash";
|
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
@ -303,9 +302,9 @@ export function DetectorHardwareField(props: FieldProps) {
|
|||||||
|
|
||||||
const updateDetectors = useCallback(
|
const updateDetectors = useCallback(
|
||||||
(nextDetectors: JsonObject, path?: FieldPathList) => {
|
(nextDetectors: JsonObject, path?: FieldPathList) => {
|
||||||
onChange(nextDetectors as unknown, path ?? ([] as FieldPathList));
|
onChange(nextDetectors as unknown, path ?? fieldPathId.path);
|
||||||
},
|
},
|
||||||
[onChange],
|
[fieldPathId.path, onChange],
|
||||||
);
|
);
|
||||||
|
|
||||||
const getTypeLabel = useCallback(
|
const getTypeLabel = useCallback(
|
||||||
@ -595,12 +594,10 @@ export function DetectorHardwareField(props: FieldProps) {
|
|||||||
const handleInstanceChange = (
|
const handleInstanceChange = (
|
||||||
nextValue: unknown,
|
nextValue: unknown,
|
||||||
path: FieldPathList,
|
path: FieldPathList,
|
||||||
_errors?: ErrorSchema,
|
errors?: ErrorSchema,
|
||||||
_id?: string,
|
id?: string,
|
||||||
) => {
|
) => {
|
||||||
const nextDetectors = cloneDeep(detectors);
|
onChange(nextValue, path, errors, id);
|
||||||
lodashSet(nextDetectors, path, nextValue);
|
|
||||||
updateDetectors(nextDetectors);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -623,17 +620,16 @@ export function DetectorHardwareField(props: FieldProps) {
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
detectorSchemaByType,
|
detectorSchemaByType,
|
||||||
detectors,
|
|
||||||
getInstanceUiSchema,
|
getInstanceUiSchema,
|
||||||
disabled,
|
disabled,
|
||||||
errorSchema,
|
errorSchema,
|
||||||
fieldPathId,
|
fieldPathId,
|
||||||
hideError,
|
hideError,
|
||||||
|
onChange,
|
||||||
onBlur,
|
onBlur,
|
||||||
onFocus,
|
onFocus,
|
||||||
readonly,
|
readonly,
|
||||||
registry,
|
registry,
|
||||||
updateDetectors,
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user