让我们详细判断一下你的第131-144行:
const onChange = (immutableTree, config) => {
immutableTree = immutableTree; // <-- why are you assigning the same var to itself?
config = config; // <-- why are you assigning the same var to itself?
updateResult(); // <-- you are not passing any variables here
const jsonTree = getTree(immutableTree);
const { logic, data, errors } = jsonLogicFormat(immutableTree, config);
};
const updateResult = throttle(() => {
setState({ tree: immutableTree, config: config }); // <-- but here you expect variables to be used
}, 100);
解决方案是:
更正版本:
const onChange = (immutableTree, config) => {
updateResult(immutableTree, config);
const jsonTree = getTree(immutableTree);
const { logic, data, errors } = jsonLogicFormat(immutableTree, config);
};
const updateResult = throttle((immutableTree, config) => {
setState({ tree: immutableTree, config });
}, 100);