I am getting this error in my code. I am able to read the correct state from my Redux Chrome extension though. I don't know where is the error coming from. I think it comes from.
TopTracks.propTypes = {
getHashParams: PropTypes.func.isRequired,
getMyTopTracks: PropTypes.func.isRequired,
myTopTracks: PropTypes.arrayOf(PropTypes.object),
}
const mapStateToProps = state => ({
myTopTracks: state.music.myTopTracks
})
Have I managed the mapStateToProps and PropTypes correctly? Because there is no sign of its object content: myTopTrackName and myTopTrackImage
Here is the full code:
class TopTracks extends Component{
componentWillMount(){
this.props.getMyTopTracks(getHashParams())
}
render(){
let link = `${ window.location.href }`
link = `/prueba/${link.substring(link.indexOf('#'))}`
return(
<div className="TopTracks">
Now Playing: { this.props.myTopTracks[0].myTopTrackName }
<img src={ this.props.myTopTracks[0].myTopTrackImage } alt="Top Track Album" style={{ width: 300 }} />
<Button href={ link }>Continue</Button>
</div>
)
}
}
TopTracks.propTypes = {
getHashParams: PropTypes.func.isRequired,
getMyTopTracks: PropTypes.func.isRequired,
myTopTracks: PropTypes.arrayOf(PropTypes.object),
}
const mapStateToProps = state => ({
myTopTracks: state.music.myTopTracks
})
export default connect(mapStateToProps, { getHashParams, getMyTopTracks } )( TopTracks )