diff -r abf9f3ff2635 -r 4cfeabef7d5e client/src/components/Sessions.js --- a/client/src/components/Sessions.js Mon Jun 12 18:09:13 2017 +0200 +++ b/client/src/components/Sessions.js Mon Jun 12 18:12:38 2017 +0200 @@ -9,10 +9,14 @@ class Sessions extends Component { - createNewSession = () => { - const result = this.props.actions.createNewSession(); - // FIXME Feels ugly, change location after state has changed? - this.props.history.push('/sessions/' + result.session.id) + createSession = () => { + this.props.sessionsActions.createSession(); + } + + componentDidUpdate = () => { + if (this.props.currentSession) { + this.props.history.push('/sessions/' + this.props.currentSession._id) + } } render() { @@ -25,13 +29,13 @@ {this.props.sessions.map((session) => this.props.history.push('/sessions/' + session.id)}> - {session.title || 'No title'} {session.id} {moment(session.date).format('DD/MM/YYYY')} + key={session._id} + onClick={() => this.props.history.push('/sessions/' + session._id)}> + {session.title || 'No title'} {session._id} {moment(session.date).format('DD/MM/YYYY')} )} - + @@ -49,7 +53,7 @@ function mapDispatchToProps(dispatch) { return { - actions: bindActionCreators(sessionsActions, dispatch) + sessionsActions: bindActionCreators(sessionsActions, dispatch) } }