Ich versuche, Notizen zu einem Aufgabenobjekt hinzuzufügen, aber was ich bis jetzt hinzugefügt habe, fügt es allen Aufgaben hinzu. Wenn ich verschiedene Möglichkeiten ausprobiere, kompiliert es nicht. Die Object.assign nicht wie nach dem .push kommen()Hinzufügen von 2 Ebenen tief in Redux Reducer
Wenn es um alle Aufgaben ergänzt:
let taskReducer = function(tasks = [], action) {
switch (action.type) {
case 'ADD_NOTE':
return tasks.map((task) => {
const { notes } = task;
const { text } = action;
notes.push({
text,
id: notes.length,
})
return task.id === action.id ?
Object.assign({}, { task, notes }) : task
})
Wenn es nicht kompiliert:
let taskReducer = function(tasks = [], action) {
switch (action.type) {
case 'ADD_NOTE':
return tasks.map((task) => {
return task.id === action.id ?
const { notes } = task;
const { text } = action;
notes.push({
text,
id: notes.length,
})
Object.assign({}, { task, notes }) : task
})
yess Vielen Dank. Mehr lernen jeden Tag :) –