我试图在我的减速器中使用传播属性,但它返回一个无效的语法错误。我的构建支持使用扩展运算符,因为我只在我的减速器中得到错误。
auth_types.js
export const AUTH_USER = 'AUTH_USER'
export const UNAUTH_USER = 'UNAUTH_USER'
auth_actions.js
import { AUTH_USER, UNAUTH_USER } from './auth_types'
export function signinUser({ email, password }) {
return function(dispatch) {
axios.post(`${ROOT_URL}/signin`, { email, password })
.then(response => {
dispatch({ type: AUTH_USER })
browserHistory.push('/feature')
})
}
}
减速器.js
import { AUTH_USER, UNAUTH_USER } from '../actions/auth_types'
export default function(state = {}, action) {
switch(action.type) {
case AUTH_USER:
return { ...state, authenticated: true }
case UNAUTH_USER:
return { ...state, authenticated: false }
}
return state
}