question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I specify <Router /> basename?

See original GitHub issue

How can I specify a router basename?

With the <BrowserRouter /> component in react-router v4, there is a basename prop:

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

Is there a way to access or use this in the <Router /> component provided in mirrorx?

import mirror, {Router, render} from 'mirrorx'
render((
    <Router basename="/calendar"> // no basename prop... this doesn't work
        ...
    </Router>
), document.getElementById('foo'));

thanks! 😄

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
island205commented, Aug 23, 2017

@blairbodnar you could pass an history instance to Router function:

import createHistory from 'history/createBrowserHistory'
import mirror, {Router, render} from 'mirrorx'

const history = createHistory({basename: '...'})
render((
    <Router history={history} >
        ...
    </Router>
), document.getElementById('foo'));
1reaction
llh911001commented, Aug 23, 2017

Yeah, that’s a problem currently, 'cause the ConnectedRouter provided by react-router-redux is a top-level Router which doesn’t handle props like basename or getUserConfirmation.

We’ll figure out this, thanks for response!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring app's basename in react-router - Stack Overflow
The basename comes into play in several places: static asset compilation in Webpack; react-router main configuration; specifying redirect routes ...
Read more >
basename prop - React Router Quick Start Guide [Book]
basename prop The basename prop is used to provide a base URL path for all the locations in the application. For example, if...
Read more >
BrowserRouter - React Router: Declarative Routing for React.js
basename : string. The base URL for all locations. If your app is served from a sub-directory on your server, you'll want to...
Read more >
[Bug]: v6 BrowserRouter set basename, not match “/” #8427
This is the expected behavior. You need to include the basename in the URL for the page itself for the Router to match...
Read more >
Add a Base URL to an App Using Redux and React Router
Adding basename in the BrowserRouter component ensures that all the links in the routes are prefixed with the base URL.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found