使用 useState 对设定值反应触发事件或触发方法

React fire event or fire method on set value with useState

对于这样定义的变量:

const [voivodeshipDict, setVoivodeshipDictValues] = useState<IDictionary[]>([] as IDictionary[]);

对于每个调用 'setVoivodeshipDictValues' 我想在设置值后触发其他代码。热衷于实施吗?

对不起我的英语。

我想你正在寻找 useEffect() 钩子:

useEffect(() => {
  // Do stuffs whenever voivodeshipDict is changed
}, [voivodeshipDict])