From f45dc1edf7f9d32e5cfcf23f5a78a5278d2f2833 Mon Sep 17 00:00:00 2001 From: Chika Date: Tue, 1 Sep 2020 21:24:28 +0300 Subject: [PATCH] add debounce delay constant --- src/client/Elements/Input.jsx | 3 ++- src/constants/debounce.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 src/constants/debounce.js diff --git a/src/client/Elements/Input.jsx b/src/client/Elements/Input.jsx index b8e8095..1f03316 100644 --- a/src/client/Elements/Input.jsx +++ b/src/client/Elements/Input.jsx @@ -3,11 +3,12 @@ import { useStores } from 'client/hooks/useStores'; import { observer } from 'mobx-react'; import React, { useEffect, useState } from 'react'; import { useDebounce } from 'use-debounce'; +import { DEBOUNCE_DELAY } from '../../constants/debounce'; const Input = ({ readonly, placeholder, bindedValueName, computedValue }) => { const { calculationStore } = useStores(); const [currentValue, setCurrentValue] = useState(undefined); - const [debouncedValue] = useDebounce(currentValue, 850); + const [debouncedValue] = useDebounce(currentValue, DEBOUNCE_DELAY); const sourceValue = calculationStore.values[bindedValueName]; diff --git a/src/constants/debounce.js b/src/constants/debounce.js new file mode 100644 index 0000000..3bc0649 --- /dev/null +++ b/src/constants/debounce.js @@ -0,0 +1 @@ +export const DEBOUNCE_DELAY = 800;