I am trying to use connect in redux react as
Connect (mapstate.., mapdis..) (withstyles(dashboardstyle)(dashboard)
The above works fine but I need to add withRouter as well. Below change gives error Connect (mapstate.., mapdis..) (withstyles(dashboardstyle), withrouter(dashboard))
Whenever I add it gives exception such as cannot use class as a function. Any ideas how this can be fixed
You will need to install recompose:
npm i -s recompose
Then in your component:
import compose from 'recompose/compose'
export default compose(
withStyles(styles),
connect(mapStateToProps, mapDispatchToProps)
)(withRouter(Dashboard))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With