When I get to my homepage, I have a current state that is an object made of objects that are my articles.
articles:
0: {id:'3',body:'ballon pied ball…football'}
1: {id:'2',body:'Encore du Lorem … article'}
2: {id:'1',body:'Lorem Ipsum Dolo… article'}
It corresponds to the list of article on the homepage; when I click on one of them, it should redirect me to the specific page of the article where I can read it. (/article/:id)
So I try to create an Article component that would render the title, subtitle and body of it. But I get 'props is undefined' as an error:
Article.js
component:
import React from 'react';
import { connect } from 'react-redux';
const Article = ({match}) => (
<div className="aboutpage-wrapper">
<div className="container">
<h1>{match.params.id}</h1>
{console.log(props)}
{/* <h2>{props.article.title}</h2>
<h3>{props.article.subtitle}</h3>
<p>{props.article.body}</p>*/}
</div>
</div>
);
const mapStateToProps = state => ({ article: state.articles[1] });
// I try to access articles[1] just to see if it works.
export default connect(mapStateToProps)(Article);
any idea ?