Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bindActionCreators expected a function actionCreator for key 'ACCOUNT_LOGIN', instead received type 'string' #2457

Closed
muscaiu opened this issue Jun 19, 2017 · 2 comments

Comments

@muscaiu
Copy link

muscaiu commented Jun 19, 2017

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:

enter image description here

@elrumordelaluz
Copy link

elrumordelaluz commented Jun 19, 2017

@muscaiu answered in Stackoverflow

@muscaiu muscaiu closed this as completed Jun 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants