4 ms·
Anybody else having trouble with the link that they provide to their "Quick Start" documentation? I can't see all the code unless I zoom out on it: https://re
by rcurry 10y ago
Anybody else having trouble with the link that they provide to their "Quick Start" documentation?
I can't see all the code unless I zoom out on it:
https://react-router-website-xvufzcovng.now.sh/quick-start https://react-router-website-xvufzcovng.now.sh/quick-start
- timdorr 10y agoThat version of the site will work best with Chrome. The newer version will fix for Firefox: https://react-router-website-xvufzcovng.now.sh/ https://react-router-website-xvufzcovng.now.sh/ The next build (now.sh versions URLs) will have both working. Sorry about that!
- bostonvaulter2 10y agoQuick question, is it necessary to render a single component within a Router? All the examples except the quick-start example seem to do so.
- timdorr 10y agoYes, 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.
- bostonvaulter2 10y agoYup, seeing that too. They made some changes to that since last night when I was first looking at it. In particular they were importing `Router` instead of `BrowserRouter`. `Router` doesn't exist. Also based on my testing you need to render a single component inside router, so wrap everything in a <div> like the basic example does: https://react-router-website-xvufzcovng.now.sh/basic https://react-router-website-xvufzcovng.now.sh/basic