Skip to content
Advertisement

mapStateToProps & mapActionsToProps not firing in react component

I have a component (SearchFilter.js) and am using connect to trigger mapStateToProps and mapActionsToProps on export.

Trouble is, mapStateToProps isn’t firing — no props (neither state nor actions) show up in React DevTools and I can’t even console log from inside mapStateToProps.

I’ve tried looking at various Stack Overflow threads but they mostly seem to be typos, or the actions themselves not working.

What’s more, I’ve got an almost identical redux setup for another component (Counter.js) that woks perfectly.

I think it could have something to do with how I provide the store/route to components (see App.js below) as React.Provider shows up in React DevTools for the Counter but not SearchFilter.

Here’s the SearchFilter component:

JavaScript

App.js

JavaScript

EDIT: Where I’ve implemented this component in the Home.js view:

JavaScript

Advertisement

Answer

Try to remove the “export” when you declare the class component, maybe that helps.

change

JavaScript

to

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement