通过传递其ID在React中获取数据属性
我是新来的React,并且有一个我不知道如何解决的问题 - 加载页面后,我将相当大的数据存储在Redux工具包中 - 一系列对象。每个对象都有自己的ID。
接下来,经过一定的用户操作,我要获得对象ID,我需要从中获取数据 - 我认为每个用户单击,映射整个数组并找到正确的ID IS NES'最有效的方法。是否可以创建一些可以通过传递其ID而不映射整个数组的ID来为我提供有关对象的信息?类似的事情 -
getDataFromId(id) - and it would return object's data.
处理此类问题的最有效方法是什么?
i'm new into React and I have a problem that I don't know how to solve - after loading page I'm storing pretty big data in Redux toolkit - an array of objects. Each object has its own id.
Next, after some user action, i'm getting the object ID and I need to get data from it - I think that every user click, mapping the whole array and find the item with correct ID isn't the most effective way. Is it possible to create something that would give me the info about the object stored in Redux by passing it's ID without mapping whole array? Something like -
getDataFromId(id) - and it would return object's data.
What is the most effective way to deal with problems like that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论