fix loop variable not sync well

This commit is contained in:
hjlarry 2025-10-14 10:10:34 +08:00
parent 79fb977f10
commit ebe7303894
1 changed files with 4 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import {
useCallback,
useEffect,
useRef,
} from 'react'
import produce from 'immer'
@ -26,6 +27,9 @@ const useConfig = (id: string, payload: LoopNodeType) => {
const { inputs, setInputs } = useNodeCrud<LoopNodeType>(id, payload)
const inputsRef = useRef(inputs)
useEffect(() => {
inputsRef.current = inputs
}, [inputs])
const handleInputsChange = useCallback((newInputs: LoopNodeType) => {
inputsRef.current = newInputs
setInputs(newInputs)