我有一个reducer,它有switch语句但是switch语句中的变量赋值通过了一个错误?
var answers, payload;
switch (action.type) {
case ANSWER_FETCH_FAILED:
return Object.assign({}, initialState, action.payload);
case REMOVE_ANSWERS:
// condition for removing the user answers from answers
/*line 42 */
answers = Object.assign([], initialState.answers),
payload = Object.assign({}, action.payload);
// removing the deleted answer
answers = answers.filter(ans => ans.authorId !== payload.authorId);
// deleting the user id from payload
delete payload.authorId;
return Object.assign({}, initialState, { answers }, payload);
case ANSWERED:
/*line 50 */
answers = Object.assign([], initialState.answers),
payload = Object.assign({}, action.payload);
return Object.assign({}, initialState, action.payload);
default:
return initialState;
}
这是反应中显示的错误
./双人床/reducers/post reducer.就是
第42行:预期赋值或函数调用,而是看到表达式no-unused-expressions
第50行:预期赋值或函数调用,而是看到表达式no-unused-expressions
用分号,
替换第42行和第50行末尾的逗号;
。
从
answers = Object.assign([], initialState.answers),
至
answers = Object.assign([], initialState.answers);