反应-从数组中删除项目而不重新呈现列表

如何解决反应-从数组中删除项目而不重新呈现列表

我无法理解为什么此代码无法正常工作。它将状态下的人员数组中的项目删除,但不会重新呈现列表。

// Before running the sample:
 * // - Enable the API at:
 * //   https://console.developers.google.com/apis/api/androidpublisher.googleapis.com
 * // - Login into gcloud by running:
 * //   `$ gcloud auth application-default login`
 * // - Install the npm module by running:
 * //   `$ npm install googleapis`
 *
 * const {google} = require('googleapis');
 * const androidpublisher = google.androidpublisher('v3');
 *
 * async function main() {
 *   const auth = new google.auth.GoogleAuth({
 *     // Scopes can be specified either as an array or as a single,space-delimited string.
 *     scopes: ['https://www.googleapis.com/auth/androidpublisher'],*   });
 *
 *   // Acquire an auth client,and bind it to all future calls
 *   const authClient = await auth.getClient();
 *   google.options({auth: authClient});
 *
 *   // Do the magic
 *   const res = await androidpublisher.purchases.subscriptions.get({
 *     // The package name of the application for which this subscription was purchased (for example,'com.some.thing').
 *     packageName: 'placeholder-value',*     // The purchased subscription ID (for example,'monthly001').
 *     subscriptionId: 'placeholder-value',*     // The token provided to the user's device when the subscription was purchased.
 *     token: 'placeholder-value',*   });
 *   console.log(res.data);
 *
 *   // Example response
 *   // {
 *   //   "ackNowledgementState": 0,*   //   "autoRenewing": false,*   //   "autoResumeTimeMillis": "my_autoResumeTimeMillis",*   //   "cancelReason": 0,*   //   "cancelSurveyResult": {},*   //   "countryCode": "my_countryCode",*   //   "developerPayload": "my_developerPayload",*   //   "emailAddress": "my_emailAddress",*   //   "expiryTimeMillis": "my_expiryTimeMillis",*   //   "externalAccountId": "my_externalAccountId",*   //   "familyName": "my_familyName",*   //   "givenname": "my_givenname",*   //   "introductoryPriceInfo": {},*   //   "kind": "my_kind",*   //   "linkedPurchasetoken": "my_linkedPurchasetoken",*   //   "obfuscatedExternalAccountId": "my_obfuscatedExternalAccountId",*   //   "obfuscatedExternalProfileId": "my_obfuscatedExternalProfileId",*   //   "orderId": "my_orderId",*   //   "paymentState": 0,*   //   "priceAmountMicros": "my_priceAmountMicros",*   //   "priceChange": {},*   //   "priceCurrencyCode": "my_priceCurrencyCode",*   //   "profileId": "my_profileId",*   //   "profileName": "my_profileName",*   //   "promotionCode": "my_promotionCode",*   //   "promotionType": 0,*   //   "purchaseType": 0,*   //   "startTimeMillis": "my_startTimeMillis",*   //   "userCancellationTimeMillis": "my_userCancellationTimeMillis"
 *   // }
 * }

我不明白为什么不重新渲染。 我正在StackBlitz上执行此操作,因此您可以在此链接上对其进行测试 https://react-ts-j1kkcp.stackblitz.io

解决方法

您需要解构新列表:setPeople([...aux]);否则React将认为一切都没有改变。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?