fix switching page causes setting to crash

This commit is contained in:
“boz”
2022-03-22 15:41:47 +08:00
parent 880cfeddee
commit 639dcf0f07

View File

@@ -26,6 +26,9 @@ const SET_CONCURRENT_WORKERS_MUTATION = gql`
const ScannerConcurrentWorkers = () => {
const { t } = useTranslation()
const workerAmountServerValue = useRef<null | number>(null)
const [workerAmount, setWorkerAmount] = useState(0)
const workerAmountQuery = useQuery<concurrentWorkersQuery>(
CONCURRENT_WORKERS_QUERY,
{
@@ -41,9 +44,6 @@ const ScannerConcurrentWorkers = () => {
setConcurrentWorkersVariables
>(SET_CONCURRENT_WORKERS_MUTATION)
const workerAmountServerValue = useRef<null | number>(null)
const [workerAmount, setWorkerAmount] = useState(0)
const updateWorkerAmount = (workerAmount: number) => {
if (workerAmountServerValue.current != workerAmount) {
workerAmountServerValue.current = workerAmount