I am starting with react, and I noticed the following coding styles in many projects:
Method 1:
const Date = styled.h3`
margin: 0 1rem 0.5rem 1rem;
color: gray;
`
const ReadingTime = styled.h4`
margin: 0 1rem 1.5rem 1rem;
color: gray;
`
const Excerpt = styled.p`
margin: 0 1rem 1rem 1rem;
line-height: 1.6;
`
<Post>
<Link to={`/${slug}/`}>
<Date>{publishDate}</Date>
<ReadingTime>{timeToRead} min read</ReadingTime>
<Excerpt
dangerouslySetInnerHTML={{
__html: body.childMarkdownRemark.excerpt,
}}
/>
</Link>
</Post>
Method 2:
Now what if I just use:
<Post>
<Link to={`/${slug}/`}>
<div className={'date'}>{publishDate}</div>
<div className={'time'}>{timeToRead} min read</div>
<div className={'excerpt'}
dangerouslySetInnerHTML={{
__html: body.childMarkdownRemark.excerpt,
}}
/>
</Link>
</Post>
and style everything in a css file.
Which method is best practice when creating react website? why?