React - expressions must have one parent element?

后端 未结 7 1449
再見小時候
再見小時候 2020-11-30 02:02

I\'m relatively new to React and I\'m wondering what\'s the standard here.

Imagine I have a react-router like this one:



        
7条回答
  •  忘掉有多难
    2020-11-30 02:45

    Faced the same error in a similar situation (React Native).

    export default class App extends React.Component {
      render() {
        return (
          
          
        );
      }
    }
    

    As indicated in the error prompt the JSX expression requires to have one parent element, hence wrap the elements in the return expression with a parent element. The flex: 1 style was added to allow the element assume the height of the entire screen.

    export default class App extends React.Component {
      render() {
        return (
          
            
            
          
        );
      }
    }
    

提交回复
热议问题