错误:动作必须是普通对象。使用自定义中间件对React Native进行异步操作

时间:2019-08-26 07:18:50

标签: react-native react-redux

...
import { connect } from "react-redux";
import { AuthActions } from "./actions";
import { bindActionCreators } from "redux";
...
class LoginComponent extends Component {
   onLogin() {
      this.props.actions.authentication(true, response => {
         // ...
      });  
   }
   ...
   render() {
      // ... render action onLogin() function when button onPress
   }
}

const mapStateToProps = state => {
  return {};
};

const mapDispatchToProps = dispatch => {
  return { actions: bindActionCreators(AuthActions, dispatch) };
};

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(LoginComponent);

在actions.js上

...
export const authentication = (login, callback) => dispatch => {
    // call api and dispatch action case
    // ...
};

当我按下按钮时,显示此错误

error

0 个答案:

没有答案