Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for BrowserRouter are incorrect #7197

Closed
jjsmclaughlin opened this issue Mar 17, 2020 · 1 comment
Closed

Docs for BrowserRouter are incorrect #7197

jjsmclaughlin opened this issue Mar 17, 2020 · 1 comment

Comments

@jjsmclaughlin
Copy link

jjsmclaughlin commented Mar 17, 2020

The docs give incorrect usage for the BrowserRouter tag. A self-closing tag as seen in the docs will have no effect. You need to wrap your BrowserRouter tag around all your Links and other routing tags for it to have an effect. See here:

https://reacttraining.com/react-router/web/api/BrowserRouter/basename-string

The example as given is wrong:

<BrowserRouter basename="/calendar" />
<Link to="/today"/> // renders <a href="/calendar/today">

This will not render href="/calendar/today" as stated. It will render href="/today".

The example should read:

<BrowserRouter basename="/calendar">
    <Link to="/today"/>
    <Link to="/tomorrow"/>
    ...
</BrowserRouter>
@pshrmn
Copy link
Contributor

pshrmn commented Mar 17, 2020

I think that the idea with that documentation is that the Link is a child somewhere or the BrowserRouter, but a PR to make this change would be appreciated.

@remix-run remix-run deleted a comment from smkamranqadri Apr 22, 2020
@timdorr timdorr closed this as completed Apr 22, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants