Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 使用useState根据设定值对火灾事件或火灾方法作出反应_Reactjs_Use State - Fatal编程技术网

Reactjs 使用useState根据设定值对火灾事件或火灾方法作出反应

Reactjs 使用useState根据设定值对火灾事件或火灾方法作出反应,reactjs,use-state,Reactjs,Use State,对于以这种方式定义的变量: const [voivodeshipDict, setVoivodeshipDictValues] = useState<IDictionary[]>([] as IDictionary[]); const[voivodeshipDict,setVoivodeshipDictValues]=useState([]作为IDictionary[]); 对于每个调用“setVoivodeshipDictValues”,我希望在设置值后触发其他代码。实施这一点

对于以这种方式定义的变量:

const [voivodeshipDict, setVoivodeshipDictValues] = useState<IDictionary[]>([] as IDictionary[]);
const[voivodeshipDict,setVoivodeshipDictValues]=useState([]作为IDictionary[]);
对于每个调用“setVoivodeshipDictValues”,我希望在设置值后触发其他代码。实施这一点很热吗


对不起,我说的是英语。

我想你在找
useffect()
hook:

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

我想您正在寻找
useffect()
hook:

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

我认为您可以在依赖项数组中使用useeffect钩子和“voivodeshipDict”,并将要运行的代码放在其中。我认为您可以在依赖项数组中使用useeffect钩子和“voivodeshipDict”,并将要运行的代码放在其中