-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Description
bindActionCreators expected a function actionCreator for key 'ACCOUNT_LOGIN', instead received type 'string'.
I started getting this error today out of the blue for all bindActionCreators
in the app.
I even went to older GIT history where i'm sure i wasn't having this error, and now it's there too.
The app still works, but the errors pop-up on each route change.
Anyone had this problem before? Or any idea where it could came from? I can provide more code, if bellow is not sufficient.
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);
Action:
export const ACCOUNT_LOGIN = 'ACCOUNT_LOGIN';
export function login(username, password) {
return {
type: ACCOUNT_LOGIN,
username,
password,
loggedIn: false,
loading: false
};
...
Reducer:
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
});
}
Error:
Metadata
Metadata
Assignees
Labels
No labels