reactjs - I want to use two tr in render() { return -


i want use 2 tr tags in return below:

render() {   return<tr>row1</tr><tr>row2</tr> } 

and gives me error: adjacent jsx elements must wrapped in enclosing tag.

i know need wrap these in common component. if wrap there in div tag example:

return <div><tr>row1</tr><tr>row2</tr></div> 

then layout changes.

is there way achieve required.

if want render 2 rows without parent wrapping them (like td, table or so), suggest create second component "wraps" children accordingly. however, works react16 onwards.

const main = props => {  return props.children } 

in render method:

render() {   return (     <main>        <tr>row 1</tr>       <tr>row 2</tr>     </main>   ) } 

there's npm package handles if want: https://github.com/gajus/react-aux


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -