O
O
Oleg Drapeza2016-06-14 13:11:32
JavaScript
Oleg Drapeza, 2016-06-14 13:11:32

How to reopen current React.js route after page reload?

Good afternoon!
React renders on the client, so the question is about client-side routing.
Let's say we followed the link, and we are on the path localhost: 8080/foo
<Route path='foo' component={FooBar} />
After reloading the page, we will get a 404 error.
Is it possible, by reloading the page, to open the component along the current path, for example, by redirecting to index.html, and following the link from window.location again?
browserHistory.push('/some/path')
Same question if you open the link in a new tab.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2016-06-14
@maxfarseer

Do I understand correctly that you have a project where react renders only some of the views? (ie, only some pages?)
In that case, you can make separate builds for each page without using routing at all. Or, why do you need it in this case?
That is: there is an about page in react, make bundle-about.js for it, bundle-contacts.js for contacts in react, and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question