How can I utilize the Post
component in a way that assigns unique classes to new and old posts following BEM recommendations?
- Assign a unique className to every element
- Avoid cascading dependencies like (
.posts-new post
or.posts-old post
) - Each component should define a new Block on its outermost element
I want the className
to distinguish between new and old posts, such as post-new
and post-old
.
One possibility is to pass "new" or "old" via a props attribute (like type="old"
) to the Post component and dynamically generate the className. Is this the recommended approach or is there another technique I'm overlooking?
// Display new posts
Posts className="posts-new"
Post className="?"
// Display old posts
Posts className="posts-old"
Post className="?"