Practice
This is a common pattern in React used to return components with several elements. Fragments let you group a list of children without adding extra nodes to the DOM.
render() {
return (
<React.Fragment>
<ChildA />
<ChildB />
<ChildC />
</React.Fragment>
)
}
There is also a shorter syntax , but it is not supported in many tools:
render() {
return (
<>
<ChildA />
<ChildB />
<ChildC />
</>
)
}
This is a common pattern in React used to return components with several elements. Fragments let you group a list of children without adding extra nodes to the DOM.
render () { return ( < React.Fragment > < ChildA /> < ChildB /> < ChildC /> </ React.Fragment > ) }
There is also a shorter syntax , but it is not supported in many tools:
render () { return ( <> < ChildA /> < ChildB /> < ChildC /> < / >
)
}
Comments