bindActionCreators expects an actionCreator function for the key 'ACCOUNT_LOGIN', instead it gets the type 'string'.
I started getting this error today unexpectedly for all bindActionCreators in the application.
I even went to the older GIT story, where I am sure that I did not have this error, and now it also has.
The application still works, but there are pop-up errors every time you change the route.
Has anyone had this problem before? Or any idea where this could come from? I can provide more code if not enough.
Container:
import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import account from '../components/account'; import * as AccountActions from '../actions/account'; function mapStateToProps(state) { return { username: state.account.username, password: state.account.password, loggedIn: state.account.loggedIn, registred: state.account.registred, loading: state.account.loading, clientId: state.account.clientId }; } function mapDispatchToProps(dispatch) { return bindActionCreators(AccountActions, dispatch); } export default connect(mapStateToProps, mapDispatchToProps)(account);
Act:
export const ACCOUNT_LOGIN = 'ACCOUNT_LOGIN'; export function login(username, password) { return { type: ACCOUNT_LOGIN, username, password, loggedIn: false, loading: false }; ...
Dilution:
import { ACCOUNT_LOGIN, } from '../actions/account'; type actionType = { type: string }; const initialState = { username: '', password: '', loggedIn: false, registred: false, loading: false, clientId: '' }; export default function account(state = initialState, action: actionType) { switch (action.type) { case ACCOUNT_LOGIN: return Object.assign({}, state, { username: action.username, password: action.password, loggedIn: action.loggedIn, loading: action.loading }); }
Mistake:

reactjs redux
Cristian muscalu
source share