1, in React in, return the contents of only one root node, we need a package element
This element is usually wrapped div, examples are as follows:
{the App the extends the Component class the render () { return ( < div > < h1 of > title </ h1 of > < H2 > subtitled </ H2 > </ div > ); } }
At this time #root the structure:
2, if not div, will complain
Examples are as follows:
{the App the extends the Component class the render () { return ( < h1 of > title </ h1 of > < H2 > subtitled </ H2 > ); } }
3, without div solution: replace with React.Fragment
Examples are as follows:
class App extends Component { render() { return ( <React.Fragment> <h1>大标题</h1> <h2>小标题</h2> </React.Fragment> ); } }
At this point #root under construction will not be more of a "annoying" friends of div