mirror of
https://github.com/langgenius/dify.git
synced 2026-05-02 06:56:29 +08:00
Revert "example of remove useEffect" (#25418)
This commit is contained in:
parent
4c92e63b0b
commit
eb52216a9c
@ -60,18 +60,22 @@ const ValueContent = ({
|
|||||||
const [fileValue, setFileValue] = useState<any>(formatFileValue(currentVar))
|
const [fileValue, setFileValue] = useState<any>(formatFileValue(currentVar))
|
||||||
|
|
||||||
const { run: debounceValueChange } = useDebounceFn(handleValueChange, { wait: 500 })
|
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) : '')
|
|
||||||
|
|
||||||
if (showFileEditor)
|
// update default value when id changed
|
||||||
setFileValue(formatFileValue(currentVar))
|
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])
|
||||||
|
|
||||||
const handleTextChange = (value: string) => {
|
const handleTextChange = (value: string) => {
|
||||||
if (currentVar.value_type === 'string')
|
if (currentVar.value_type === 'string')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user