A
A
Azad Kichibekov2020-12-29 23:53:45
JavaScript
Azad Kichibekov, 2020-12-29 23:53:45

How to edit a large amount of data in an array?

I have a dynamic array stored in a state in which the nth number of objects is: [{name: "example", id:45, {}...], Each object is 1 input, An event is hung on each field to change fields by id , but due to a large number of sets and changing an immutable array by copying it, ui starts to slow down, how can I prevent this, or what am I doing wrong? And also the search is carried out by id, is it better to use index instead of id? I will be very grateful for your help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Antsiferov, 2020-12-30
@Babayka_od

You can make an object from an array, whose keys will be the id of the array element

[{id: 45, name: "example"}] -> {45: {id: 45, name: "example"}}

S
Sergey Melnikov, 2020-12-30
@mlnkv

https://codesandbox.io/s/loving-colden-kmzi2?file=...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question