admin 管理员组文章数量: 1184232
题意:
useState 的设置方法不会立即反映变化。
问题背景:
I am trying to learn hooks and the useState method has made me confused. I am assigning an initial value to a state in the form of an array. The set method in useState is not working for me, both with and without the spread syntax.
我正在尝试学习 hooks,useState 方法让我感到困惑。我正在为一个状态赋一个数组形式的初始值。useState 中的设置方法对我没有效果,无论是否使用展开语法。
I have made an API on another PC that I am calling and fetching the data which I want to set into the state.
我在另一台电脑上创建了一个 API,我正在调用它并获取我想设置到状态中的数据。
Here is my code:
这是我的代码:
<div ></div>
<script type="text/babel" defer>
// import React, { useState, useEffect } from "react";
// import ReactDOM from "react-dom";
const { useState, useEffect } = React; // web-browser variant
本文标签: method set useState Immediately change
版权声明:本文标题:The useState set method is not reflecting a change immediately 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1765487973a3385620.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论