React is a popular library for creating web apps and mobile apps.
In this article, we’ll look at some tips for writing better React apps.
All components must have an outer element surrounding them.
For instance, we can write:
return (
<div>
<Child1 />
<Child2 />
</div>
)
We have a div surrounding all the child elements.
Also, we can use a fragment to surround our components if we don’t want to render a wrapper element.
For instance, we can write:
return (
<>
<Child1 />
<Child2 />
</>
)
or:
return (
<React.Fragment>
<Child1 />
<Child2 />
</React.Fragment>
)
#software-development #web-development #programming #technology #javascript