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
After adding createBrowserHistory, the app is not working as expected #2108
Comments
I am not sure whether it works with hash urls. |
Sorry, I am not explain it clearly. The reason I want to use createBrowserHistory is I want to get the crap _k=3mr0ay and hash tag. Before I add createBrowserHistory, I use url like assets#/about?_k=3mr0ay and it works fine. But after I use it I can get assets/about working. Because of the error above. So I am not sure how to get it working properly. |
I'm not sure if it was you asking the same/similar question on SO and I gave the explanation together with the example how it should be done. |
Yes, same question. Actually I already got the stuff you gave to me working and it's no problem. Please see my question carefully. My problem here is the root url is not '/' and it's '/others/'. Before I used createBrowserHistory, I can just put path='/', but after I added it, the path '/' is not working. Error Warning: Location "/assets" did not match any routes |
lol answering in the two places sorry. as per my SO comment, just a copy here:
|
Unfortunately, I tried both All of above not working. Any idea what it should be like? Thanks. |
It's hard to tell with the amount of information you gave. I provided you with the working example. Either try the example and see what is different in your app or provide more code or even better minima failing example I can play with. |
Thanks. Probably I will try something different tomorrow and see how it is going. Hopefully below code in the example can help me a little bit.
|
feel free to ask more questions here or if you think that the issue can be closed please do so :) |
Yeah, I will close if it works. |
I've tried the const history = useBasename(createHistory)({ basename: '/animations' }) as wells as, import createBrowserHistory from 'history/lib/createBrowserHistory';
let history = createBrowserHistory(); once I add any of these, all routes stop working except the '/' route. |
please show more code and I'll be able to help |
'use strict';
import React from 'react';
import {Router, Route} from 'react-router';
import createBrowserHistory from 'history/lib/createBrowserHistory';
import App from './app';
import Homepage from './components/homepage';
import Customers from './components/customers';
import Test from './components/test';
let history = createBrowserHistory();
React.render((
<Router history={history}>
<Route component={App}>
<Route path="/" component={Homepage}/>
<Route path="test" component={Test}/>
</Route>
</Router>
),
document.querySelector('#app')); |
try this instead (remember to import <Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={Homepage} />
<Route path="test" component={Test} />
</Route>
</Router> |
Once I add this, any |
this is weird... what errors are you getting then? |
Just joining your conversation to let you know that I might be facing the same (or a quite similar) problem. When using a browser history, navigating to one of my routes results in a simple page showing "Not Found". I have no idea where this comes from, it really doesn't seem to come from my project. Clicking on |
could you reproduce it so I can have a look into it. I have no idea how to reproduce the issue |
I'm not getting any errors, Here's my test sample https://github.com/bellicose100xp/react-input just run gulp after npm install |
okay, so the problem was that you were using var historyApiFallback = require('connect-history-api-fallback'); and your connect task should look like: gulp.task('connect', function () {
connect.server({
root: ['dist'],
port: config.port,
base: config.devBaseUrl,
livereload: true,
middleware: function(connect, opt){
return [historyApiFallback({})];
}
});
}); |
that did it, it works now, would not have guessed this solution. Thank you |
|
I used the version 1-rc for react router. My route config is something like below:
And the access url is like below:
http://localhost:3001/assets# (entry point)
http://localhost:3001/assets#/about?_k=3mr0ay
However, when I added the createBrowserHistory support to the Route:
history={createBrowserHistory()}
The app is not working correctly.
The error is: Warning: Location "/assets" did not match any routes
Even I add the /assets to the path it is still not working.
What's the correct way of doing this?
The text was updated successfully, but these errors were encountered: