W
W
Wheelie2016-12-01 10:06:46
JavaScript
Wheelie, 2016-12-01 10:06:46

How to fix The root route must render a single element error in react router?

An error occurs

Uncaught Error: The root route must render a single element(…) browser.js:40

The application was created using create-react-app
The code looks something like this:
const rootRoute = {
  childRoutes: [{
    path: '/',
    component: require('./App'),
    childRoutes: [
        require('./../routes/сalendar'),
    ]
  }]
}

ReactDOM.render(
    <Router history={browserHistory} routes={rootRoute} />,
    document.getElementById('root')
);

in App:
class App extends Component {
    render() {
        return (
            <MuiThemeProvider>
                <Container />
            </MuiThemeProvider>
        );
    }
}

The Container is just a div.
In /routes/calendar:
module.exports = {
  path: 'calendar',
  getComponent(location, cb) {
    require.ensure([], require => cb(require(`./components/Calendar`).default));
  }
}

The Calendar is just a div

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Risent Veber, 2016-12-01
@Wheelie

stackoverflow.com/questions/36194806/invariant-vio...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question