Can't update in deep array with a map
Methuselah96 opened this issue · 1 comments
Methuselah96 commented
From @eldina07 on Mon, 24 Jun 2019 12:07:15 GMT
Hello there,
I have a problem to update all objects in a deep array.
My structure of elements is:
{
"name":"",
"category":"",
"notes":"",
"sections":[
{
"name":"Workout",
"exercises":[
{
"sets":[
{
"value":5,
"workload":100,
"workload_type":"kg",
"timer":120,
"repetitions":[
5, 3
]
},
{
"value":5,
"workload":100,
"workload_type":"kg",
"timer":120,
"repetitions":[
5, 2
]
}
],
}
]
}
]
}I want to add a repetition in all repetitions keys in each set, so i do:
state.updateIn(
['sections', index_section, 'exercises', index_exercise, 'sets'],
sets => sets.map(s => s.update('repetitions', repetitions => repetitions = 5))
)But i have an error: s.update is not a function. Variable s is not an immutable object but i don't know why.
Copied from original issue: immutable-js#1721
Methuselah96 commented
Can't reproduce.