example of remove useEffect (#25212)
This commit is contained in:
@@ -60,14 +60,11 @@ 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 })
|
||||||
|
|
||||||
// update default value when id changed
|
|
||||||
useEffect(() => {
|
|
||||||
if (showTextEditor) {
|
if (showTextEditor) {
|
||||||
if (currentVar.value_type === 'number')
|
if (currentVar.value_type === 'number')
|
||||||
return setValue(JSON.stringify(currentVar.value))
|
setValue(JSON.stringify(currentVar.value))
|
||||||
if (!currentVar.value)
|
if (!currentVar.value)
|
||||||
return setValue('')
|
setValue('')
|
||||||
setValue(currentVar.value)
|
setValue(currentVar.value)
|
||||||
}
|
}
|
||||||
if (showJSONEditor)
|
if (showJSONEditor)
|
||||||
@@ -75,7 +72,6 @@ const ValueContent = ({
|
|||||||
|
|
||||||
if (showFileEditor)
|
if (showFileEditor)
|
||||||
setFileValue(formatFileValue(currentVar))
|
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')
|
||||||
|
Reference in New Issue
Block a user