You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a small problem with mapStateToProps and cant find the sollutions.
The code below works, but i want to use mapStateToProps correctly as described in your videos.
If I change the line "post: posts" to "post: posts[ownProps.match.params.id]" and changed the render method from "{post[this.props.match.params.id].title}" to "{post.title}" I got the following message:
Uncaught TypeError: Cannot read property '242339' of null
I have a small problem with mapStateToProps and cant find the sollutions.
The code below works, but i want to use mapStateToProps correctly as described in your videos.
If I change the line "post: posts" to "post: posts[ownProps.match.params.id]" and changed the render method from "{post[this.props.match.params.id].title}" to "{post.title}" I got the following message:
Uncaught TypeError: Cannot read property '242339' of null
Thanks in advance!
`class PostsShow extends Component {
componentDidMount() {
const { id } = this.props.match.params;
this.props.fetchPost(id);
}
render() {
const { post } = this.props;
console.log(this.props.post);
}
}
const mapStateToProps = ({posts}, ownProps) => {
console.log(ownProps);
return {
post: posts
};
};`
The text was updated successfully, but these errors were encountered: