与redux-saga反应:this.props.action不是一个函数

时间:2018-02-02 10:55:07

标签: reactjs redux react-redux redux-saga

这是我的商店配置:

const sagaMiddleware = createSagaMiddleware();

const configureStore = () => {
    return {
        ...createStore(rootReducer,
            applyMiddleware(sagaMiddleware)),
        runSaga: sagaMiddleware.run(rootSaga)
    };
};

export default configureStore;

动作:

export const getInvoicesAction = (payload) => ({
    type: types.GET_INVOICES_REQUEST,
    payload
});

我试图在反应组件中映射DispatchToPtops:

const mapDispatchToProps = dispatch=>{
    return {
        getInvoices: (query)=> dispatch(getInvoicesAction(query))
    };
};

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

然后调用function int componentDidMount:

export class InvoicesPage extends React.Component {
    constructor() {
        super();
    }

    componentDidMount() {
        this.props.getInvoices('test');
    }

然而,在控制台中,它说this.props.getInvoices is not a function

任何解决方案?

0 个答案:

没有答案