import React from 'react';

class PostsIndex extends React.Component {
  render() {
    return (
      <div className='posts-index'>
        Posts Index
      </div>
    )
  }
}

export default PostsIndex;

import React from 'react';
import { connect } from 'react-redux';
import { fetchPosts } from '../actions';


class PostsIndex extends React.Component {
  componentDidMount() {
    this.props.fetchPosts();
  }

  render() {
    return (
      <div className='posts-index'>
        Posts Index
      </div>
    )
  }
}

export default connect(null, { fetchPosts: fetchPosts })(PostsIndex);

Call fetchPosts when PostsIndex components mounts
Call fetchPosts when PostsIndex components mounts
