Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

example of remove useEffect (#25212)

Asuka Minatoa9da8edbde40
diff --git a/web/app/components/workflow/variable-inspect/value-content.tsx b/web/app/components/workflow/variable-inspect/value-content.tsx
index a3ede311c45..2b28cd8ef4e 100644
--- a/web/app/components/workflow/variable-inspect/value-content.tsx
+++ b/web/app/components/workflow/variable-inspect/value-content.tsx
@@ -60,22 +60,18 @@ const ValueContent = ({
const [fileValue, setFileValue] = useState<any>(formatFileValue(currentVar))
const { run: debounceValueChange } = useDebounceFn(handleValueChange, { wait: 500 })
+ if (showTextEditor) {
+ if (currentVar.value_type === 'number')
+ setValue(JSON.stringify(currentVar.value))
+ if (!currentVar.value)
+ setValue('')
+ setValue(currentVar.value)
+ }
+ if (showJSONEditor)
+ setJson(currentVar.value ? JSON.stringify(currentVar.value, null, 2) : '')
- // update default value when id changed
- useEffect(() => {
- if (showTextEditor) {
- if (currentVar.value_type === 'number')
- return setValue(JSON.stringify(currentVar.value))
- if (!currentVar.value)
- return setValue('')
- setValue(currentVar.value)
- }
- if (showJSONEditor)
- setJson(currentVar.value ? JSON.stringify(currentVar.value, null, 2) : '')
-
- if (showFileEditor)
- setFileValue(formatFileValue(currentVar))
- }, [currentVar.id, currentVar.value])
+ if (showFileEditor)
+ setFileValue(formatFileValue(currentVar))
const handleTextChange = (value: string) => {
if (currentVar.value_type === 'string')