Skip to content

Instantly share code, notes, and snippets.

@Louiefigz
Created May 23, 2017 15:44
Show Gist options
  • Save Louiefigz/24ef376aaab3201d4e358fab37bb741e to your computer and use it in GitHub Desktop.
Save Louiefigz/24ef376aaab3201d4e358fab37bb741e to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { connect } from 'react-redux';
class Tasks extends Component {
render() {
const tasks = this.props.tasks.map((task, index) => <li key={index}>{task}</li>)
return (
<div>
<ul>
{tasks}
</ul>
</div>
)
}
}
const mapStateToProps = (state) => {
return {
tasks: state.tasks
};
};
// We're going to change the way that we export this file.
// export const AllTasks = connect(mapStateToProps)(Tasks);
// Now go back to App.js and change the import name AllTasks to Tasks
export default connect(mapStateToProps)(Tasks);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment