3 ms·
Yes, because we have to render props.children and normally Router is right under or near ReactDOM.render(), which only wants a single element from the component
by timdorr 10y ago
Yes, because we have to render props.children and normally Router is right under or near ReactDOM.render(), which only wants a single element from the component from the top of the tree. We were inserting a <div>, but that would screw over React Native users. So, unfortunately due to the structure of React, we have to enforce a single child.
This is improved a little bit in git, where we do a React.Children.only check: https://github.com/ReactTraining/react-router/commit/5a74d46a9fcf1b9663ba42b238ba6dd4584983ab https://github.com/ReactTraining/react-router/commit/5a74d46...
- bostonvaulter2 10y agoAh yeah adding that check should help. I wasted a good 20 minutes trying to figure it out the other day. Can the quick-start example be updated to have a single child? I would submit a PR but I was unable to find the repo.