133
rated 0 times
[
137]
[
4]
/ answers: 1 / hits: 33038
/ 7 Years ago, tue, march 14, 2017, 12:00:00
Given the following JSX:
const elems = <div><p>hello</p><p>world</p></div>
If I want to add another element to the end, is there a more idiomatic way than doing:
const moreElems = <div>{elems}<p>additional</p></div>
Maybe something like:
elems.push(<p>additional</p>)
I would be fine omitting the wrapper div
; that's just so there's only a single top-level JSX element.
More From » reactjs