E
E
Egor2016-02-20 21:02:58
JavaScript
Egor, 2016-02-20 21:02:58

How to make a site without reloading on react.js?

I use react-router and there is something like this code

ReactDOM.render(
  <Router history={hashHistory}>
    <Route path="/" component={Contents}>
      <IndexRoute component={MainContent}/>
      <Route path=":id" component={MoreItemSite} />
    </Route>
  </Router>
  , document.getElementById('app')
);

everything works fine on the server, everything is rendered without reloading the page. But from hashHistory, the address turns out to be ugly. In general, hashHistory was replaced with browserHistory and
in .htaccess I wrote the following
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]

Then all links go normally and the address looks normal, BUT the page is reloaded. How can I fix this issue using browserHistory ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question