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

How can I specify <Router /> basename? #22

Closed
blairbodnar opened this issue Aug 22, 2017 · 6 comments
Closed

How can I specify <Router /> basename? #22

blairbodnar opened this issue Aug 22, 2017 · 6 comments

Comments

@blairbodnar
Copy link

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 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! 😄

@llh911001
Copy link
Member

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!

@blairbodnar
Copy link
Author

Ah yeah, I see. Thanks! And great work with everything. I'm loving mirrorx so far 👍

@island205
Copy link

island205 commented 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'));

@blairbodnar
Copy link
Author

@island205 Thanks! That works great!

@llh911001
Copy link
Member

@blairbodnar It's done, now Router supports every prop BrowserRouter or HashRouter handles. Take a look at this commit, the latest version is v0.2.7.

@blairbodnar
Copy link
Author

@llh911001 Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants