import TodoListItem from '../todoListItem/todoListItem';
import React, { Component } from 'react';
import { connect } from 'react-redux';

class TodoList extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <div>
                {
                    this.props.todos.map((item, index) => {
                        return <TodoListItem key={index} todoItem={item.text} />
                    })
                }
            </div>
        );
    }
}

const mapStateToProps = (state, ownProps) => {
    return {
        todos: state.todoListRedux.todos
    };
};

export default connect(mapStateToProps)(TodoList);