对于这样定义的变量:
const [voivodeshipDict, setVoivodeshipDictValues] = useState<IDictionary[]>([] as IDictionary[]);
对于每次调用“setVoivodeshipDictValues”,我想在设置值后触发其他代码。很想实施吗?
对不起我的英语。
答案 0 :(得分:2)
我认为您正在寻找 useEffect()
钩子:
useEffect(() => {
// Do stuffs whenever voivodeshipDict is changed
}, [voivodeshipDict])