タスクオブジェクトにメモを追加しようとしていますが、これまでのところすべてのタスクにメモを追加しています。私はさまざまな方法で試してみると、コンパイルされません。それは、すべてのタスクに追加するとObject.assignは.push()の後に来て好きではありませんRedux Reducerの項目2レベルを追加する
:
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
})
は、それがコンパイルされない場合は:
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を。もっと毎日のことを学ぶ:) –