I am building a simple blogging application and the App component (root path) is overriding the "posts/new" route, and IndexRoute is not rendering the posts_index component.
Basically, Only the App is rendering. Any feedback is welcome. See Below
// routes.js
import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from './components/app';
import PostsIndex from './components/posts_index';
import PostsNew from './components/posts_new';
export default (
<Route path="/" component={App}>
<IndexRoute component={PostsIndex}/>
<Route path="posts/new" component={PostsNew}/>
</Route>
);
// app.js
import React from 'react';
import { Component } from 'react';
export default class App extends Component {
render() {
return (
<div>React simple starter</div>
);
}
}
// posts_new.js
import React, { Component } from 'react';
class PostsNew extends Component {
render() {
return (
<div>Create Posts</div>
);
}
}
export default PostsNew;
// posts_index.js
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { fetchPosts } from '../actions/index';
class PostsIndex extends Component {
componentWillMount() {
this.props.fetchPosts();
}
render() {
return (
<div>List of Blog Posts</div>
);
}
};
export default connect(null, { fetchPosts })(PostsIndex);