I am new to Redux. Now I'm trying to use redix-response-router, but I have a problem. I clicked on the links and nothing happened. My application does not display the component and does not change the URL.
I have an app.js file with the following code:
import '../stylesheets/main.scss';
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { combineReducers, createStore } from 'redux';
import { Router, Route, IndexRoute, browserHistory } from 'react-router';
import { routerReducer } from 'react-router-redux';
import rootReducer from './reducers/rootReducer';
import Home from './containers/HomePage';
import RegisterPage from './containers/RegisterPage';
import 'lazysizes';
const store = createStore(
combineReducers({
rootReducer,
routing: routerReducer
})
);
const rootElement = document.getElementById('root');
render(
<Provider store={store}>
<Router history={browserHistory}>
<Route path="/" component={Home}>
<IndexRoute component={Home} />
<Route path="foo" component={RegisterPage}/>
</Route>
</Router>
</Provider>,
rootElement
);
And I have the Navigation component used by the Home component .
import React, { Component } from 'react';
import classNames from 'classnames';
import { Link } from 'react-router';
export default class Navigation extends Component {
constructor() {
super();
this.state = {
links: [
{ href: '#', isActive: true, title: 'Home' },
{ href: '/foo', isActive: false, title: 'Lorem' }
]
};
}
render() {
return (
<nav className="navigation" role="navigation">
<ul className="navigation_list" role="list">
{this.state.links.map((link, i) => {
const linkClass = classNames({
link: true,
'link-active': link.isActive
});
return (
<li key={i} className="item" role="listitem">
<Link className={linkClass} to={link.href}>{link.title}</Link>
</li>
);
})}
</ul>
</nav>
);
}
}
When I click on the link ... nothing happens. Why?
source
share