import React from 'react'
import PropTypes from 'prop-types'
import Todo from './Todo'
class TodoList extends React.Component {
constructor(props) {
super(props);
this.state = {
value: null,
};
this.todos = [
{
id: 'ccaac',
value: '加鲁鲁',
adhere: '粘贴'
}
];
this.todos.map(todo => (
console.log(todo)
))
}
render() {
let todos = this.todos
return {this.todos.map(todo => (
<Todo id={todo.id} />
))}
}
}
export default TodoList;
import React, { Component } from 'react';
class Todo extends React.Component {
constructor(props) {
super(props);
this.state = {
value: null,
};
}
render() {
return <div className="square" onClick={() => alert('click')}>
{this.props.id}
</div>
}
}
export default Todo;
return后面不是得这样写吗?你确定是map报错,不是render报错?0-0