If I have an array that look like this:
[
{
key: some_key,
payload: { ... }
},
{
key: some_key,
payload: { ... }
},
{
key: some_key,
payload: { ... }
},
...
]
and I want to find something using a key and then modify the payload.
Is there any way other than iterating through the array?
I have several concerns about iterating
- This array is used by many async functions, I am worried that the index might be invalidated by some other functions during the iteration.
- Iteration might lead to a lower performance.
I thought about using a immutable object there, but converting to array before every re-rendering doesn't seem very efficient.
Any good idea?