From 38ea0de90771a14c0fc62a381ab02c2d5cd1bcc9 Mon Sep 17 00:00:00 2001 From: pepepeboom <166216706+pepepeboom@users.noreply.github.com> Date: Mon, 20 Jul 2026 14:28:08 +0800 Subject: [PATCH] refactor(web): avoid direct setState in effect in jina reader crawler (#25194) (#39216) Co-authored-by: Claude Fable 5 Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> --- oxlint-suppressions.json | 3 --- .../datasets/create/website/jina-reader/index.tsx | 9 +++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json index a31eaaeffb4..cd155c48af6 100644 --- a/oxlint-suppressions.json +++ b/oxlint-suppressions.json @@ -2487,9 +2487,6 @@ } }, "web/app/components/datasets/create/website/jina-reader/index.tsx": { - "eslint-react/set-state-in-effect": { - "count": 1 - }, "no-console": { "count": 1 }, diff --git a/web/app/components/datasets/create/website/jina-reader/index.tsx b/web/app/components/datasets/create/website/jina-reader/index.tsx index 6da21c114a1..4bd61eae768 100644 --- a/web/app/components/datasets/create/website/jina-reader/index.tsx +++ b/web/app/components/datasets/create/website/jina-reader/index.tsx @@ -3,7 +3,7 @@ import type { FC } from 'react' import type { CrawlOptions, CrawlResultItem } from '@/models/datasets' import { toast } from '@langgenius/dify-ui/toast' import * as React from 'react' -import { useCallback, useEffect, useState } from 'react' +import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants' import { useIntegrationsSetting } from '@/app/components/header/account-setting/use-integrations-setting' @@ -44,9 +44,6 @@ const JinaReader: FC = ({ const { t } = useTranslation() const [step, setStep] = useState(Step.init) const [controlFoldOptions, setControlFoldOptions] = useState(0) - useEffect(() => { - if (step !== Step.init) setControlFoldOptions(Date.now()) - }, [step]) const openIntegrationsSetting = useIntegrationsSetting() const handleSetting = useCallback(() => { openIntegrationsSetting({ @@ -147,6 +144,9 @@ const JinaReader: FC = ({ return } setStep(Step.running) + // fold the options panel when the step leaves `init`, + // previously synced via a setState in an effect on `step` + setControlFoldOptions(Date.now()) try { const startTime = Date.now() const res = (await createJinaReaderTask({ @@ -190,6 +190,7 @@ const JinaReader: FC = ({ console.log(e) } finally { setStep(Step.finished) + setControlFoldOptions(Date.now()) } }, [checkValid, crawlOptions, onCheckedCrawlResultChange, onJobIdChange, t, waitForCrawlFinished],