React-Router only one child

后端 未结 10 1732
执笔经年
执笔经年 2020-12-07 14:32

I keep on getting the error:

A \'Router\' may have only one child element

when using react-router.

I can\'t seem to fig

10条回答
  •  北海茫月
    2020-12-07 15:03

    Not sure if my router might be too simple, or there was a change to this rule but was following along a tutorial that mentioned this limitation (A 'Router' may have only one child element) and it allowed me to add 3 routes without giving any errors. This is the working code:

    function render() {
      ReactDOM.render(
        
          
          
          
        
        ,
        document.getElementById('root')
      );
    }
    

    And this are my dependencies:

    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.1",
    

提交回复
热议问题