import React from 'react'; import {withRouter} from 'react-router-dom'; import SignupFormContainer from './signup_form_container'; import DemoLoginContainer from './demo_container'; import NewsFeedContainer from '../posts/news_feed_container'; import PostIndexContainer from '../posts/post_index_container'; import { connect } from 'react-redux'; import {fetchAllUsers} from '../../actions/session_actions'; import {Link} from 'react-router-dom'; class MainPage extends React.Component{ constructor(props){ super(props); this.state={loading:true}; } componentDidMount(){ this.props.fetchAllUsers().then(()=>this.setState({loading:false})); } render(){ if (!this.props.currentUser){ return(

Connect with friends and the world around you.

See photos and updates

from friends in News Feed.

Share what's new

in your life on your Timeline.

Find more

of what you're looking for with Connect Search.

); }else{ return(
  • {this.props.currentUser.fname} {this.props.currentUser.lname}

    ...
  • News Feed

    ...
  • Messenger

    ...
  • Videos

    ...
  • Events

    ...
  • Pages

    ...
  • Linked In

    ...
  • Git Hub

    ...

Sponsored

); } } } const mapStateToProps = (state) => { const currentUserId = state.session.id ; return ( { currentUser:state.entities.users[currentUserId], users:state.entities.users } ); }; const mapDispatchToProps = (dispatch) => { return { fetchAllUsers: ()=>dispatch(fetchAllUsers()) }; }; export default withRouter(connect(mapStateToProps,mapDispatchToProps)(MainPage));