【发布时间】:2016-08-25 16:44:51
【问题描述】:
我正在尝试在我的减速器中使用扩展属性,但它返回时出现无效的语法错误。我的构建支持使用扩展运算符,因为我只在减速器中得到错误。
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')
})
}
}
reducer.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
}
【问题讨论】:
标签: javascript reactjs ecmascript-6 redux