Nathan Horrigan
Nathan Horrigan

Reputation: 813

mapDispatchToProps action is not a function

So I do this in container:

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

and when props is logged in browser I get:

actions: {
    fetchMakers: function() ....
}

but when I call this.props.actions.fetchMarkers(params) I get the following error:

Cannot read property 'fetchMarkers' of undefined

This is driving me nuts, Please help!

Edit:

Action:

export const fetchMarkers = (payload) => {
  return {
    type: actionTypes.fetchMarkers,
    payload
  }
}

Upvotes: 0

Views: 943

Answers (1)

Artem Mirchenko
Artem Mirchenko

Reputation: 2170

Try this case:

import { fetchMarkers } from 'path_to_makers_action';

....Code of react component....

export default connent(null, { fetchMarkers });

And in component you use: this.props.fetchMarkers()

Upvotes: 1

Related Questions