Created
May 18, 2018 11:58
-
-
Save gaurav-gogia/8a50167b4015385bb3c2746a436a08e5 to your computer and use it in GitHub Desktop.
Trying to use mapDispatchToProps without mapStateToProps. See this is what I'm trying but it keeps giving me this error: TypeError: dispatch is not a function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '../App.css' | |
import {connect} from 'react-redux'; | |
import React, {Component} from 'react'; | |
import {bindActionCreators} from 'redux'; | |
import {selectAnimal} from '../actions/actions'; | |
class Animal extends Component { | |
onClick = () => this.props.selectAnimal(this.props.animalInfo); | |
render() { | |
return ( | |
<div className="card no-selection" onClick={this.onClick}> | |
{this.props.animalInfo.name} | |
</div> | |
); | |
} | |
} | |
const mapDispatchToProps = (dispatch) => { | |
return bindActionCreators({ | |
selectAnimal | |
}, dispatch) | |
} | |
export default connect(mapDispatchToProps)(Animal); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is amazing!! Thanks, ^.^