{"action":"created","issue":{"url":"https://api.github.com/repos/ga-wdi-exercises/project4/issues/425","repository_url":"https://api.github.com/repos/ga-wdi-exercises/project4","labels_url":"https://api.github.com/repos/ga-wdi-exercises/project4/issues/425/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-exercises/project4/issues/425/comments","events_url":"https://api.github.com/repos/ga-wdi-exercises/project4/issues/425/events","html_url":"https://github.com/ga-wdi-exercises/project4/issues/425","id":197186843,"number":425,"title":"React/Redux: How to have data on first render?","user":{"login":"bcravens","id":22077300,"avatar_url":"https://avatars.githubusercontent.com/u/22077300?v=3","gravatar_id":"","url":"https://api.github.com/users/bcravens","html_url":"https://github.com/bcravens","followers_url":"https://api.github.com/users/bcravens/followers","following_url":"https://api.github.com/users/bcravens/following{/other_user}","gists_url":"https://api.github.com/users/bcravens/gists{/gist_id}","starred_url":"https://api.github.com/users/bcravens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcravens/subscriptions","organizations_url":"https://api.github.com/users/bcravens/orgs","repos_url":"https://api.github.com/users/bcravens/repos","events_url":"https://api.github.com/users/bcravens/events{/privacy}","received_events_url":"https://api.github.com/users/bcravens/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-22T14:31:24Z","updated_at":"2016-12-22T16:51:48Z","closed_at":null,"body":"In a file a have a WorkoutPage component. In it I have:\r\n\r\n```javascript\r\ncomponentDidMount() {\r\n    this.props.getWorkout(this.props.user.id, this.props.params.workout)\r\n  }\r\n```\r\n\r\nI'm getting props from a mapStateToProps function\r\n```javascript\r\n\r\nfunction mapStateToProps(state) {\r\n  return {\r\n    workout: state.workout,\r\n    user: state.auth.user\r\n  }\r\n}\r\n```\r\nIn my store, workout's initial state is an empty array. The `getWorkout` function in my componentDidMount sets a new state to workout.\r\n\r\nIf I console.log (this.props.workout)  it returns:\r\n```\r\n[]\r\n[Object]\r\n```\r\nIn the lesson plan you say `That's because a re-render will always happen because fetching data happens asynchronously`\r\n\r\nIs there a way to avoid this and have it return just `[Object]` because In the component I'd like to render `{ this.props.workout[0].name }` and .name returns undefined because of the first rendering and errors out the entire component.\r\n\r\nI would also like to use { this.props.workout[0].id } for a `getExercises` function where I pass the id as an argument and it is currently passing in undefined from the first render which errors it out. \r\n\r\nI feel like the answer is somewhere in a  `componentWillMount` or something but it doesn't seem to be working. \r\n\r\nFile in question: https://github.com/bcravens/WorkoutsClient/blob/master/src/components/workouts/WorkoutPage.js"},"comment":{"url":"https://api.github.com/repos/ga-wdi-exercises/project4/issues/comments/268841083","html_url":"https://github.com/ga-wdi-exercises/project4/issues/425#issuecomment-268841083","issue_url":"https://api.github.com/repos/ga-wdi-exercises/project4/issues/425","id":268841083,"user":{"login":"bcravens","id":22077300,"avatar_url":"https://avatars.githubusercontent.com/u/22077300?v=3","gravatar_id":"","url":"https://api.github.com/users/bcravens","html_url":"https://github.com/bcravens","followers_url":"https://api.github.com/users/bcravens/followers","following_url":"https://api.github.com/users/bcravens/following{/other_user}","gists_url":"https://api.github.com/users/bcravens/gists{/gist_id}","starred_url":"https://api.github.com/users/bcravens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcravens/subscriptions","organizations_url":"https://api.github.com/users/bcravens/orgs","repos_url":"https://api.github.com/users/bcravens/repos","events_url":"https://api.github.com/users/bcravens/events{/privacy}","received_events_url":"https://api.github.com/users/bcravens/received_events","type":"User","site_admin":false},"created_at":"2016-12-22T16:51:48Z","updated_at":"2016-12-22T16:51:48Z","body":"Thanks I'll try this out!"}}
{"actor":{"display_login":"bcravens"}}