March 2019
Intermediate to advanced
350 pages
7h 28m
English
Let's start with a very simple one. As stated previously, one of the main reasons we should prefer JSX over React's createElement function is because of its XML-like syntax, and because balanced opening and closing tags are perfect to represent a tree of nodes.
Therefore, we should try to use it in the right way and get the most out of it.
One example is as follows; whenever we have nested elements, we should always go multiline:
<div> <Header /> <div> <Main content={...} /> </div> </div>
This is preferable to the following:
<div><Header /><div><Main content={...} /></div></div>
The exception is if the children are not elements, such as text or variables. In that case, it makes sense to remain on the same line and avoid ...
Read now
Unlock full access