Created
June 19, 2019 11:43
-
-
Save tyb/bfcb1c86c9e3403ed2c175bffd27bd61 to your computer and use it in GitHub Desktop.
react non semantic component, making div a component instead of li
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Article = (props) => { | |
// Notice: <li>s are gone | |
return <div class="article"> | |
<h2 class="article__title">{ props.title }</h2> | |
{ /* ... */ } | |
</div>; | |
} | |
const ArticleList = (props) => { | |
return <div class="articles"> | |
<ul class="article-list"> | |
{ props.articles.map(article => | |
<li class="article-list__item"> | |
<Article title={article.title} { /* other props */ } /> | |
</li> | |
) } | |
</ul> | |
{ /* ... */ } | |
</div>; | |
} | |
// And now you can easily render an article inside of a sidebar – have no idea why though | |
const Sidebar = (props) => { | |
return <div class="sidebar"> | |
<div class="sidebar__article"> | |
<Article title="Look ma" { /* other props */ } /> | |
</div> | |
{ /* ... */ } | |
</div>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment