Kayut
Posted on January 17, 2019
React complains about the following code with the error: Your render method should have return statement.
Could you please explain what is exactly wrong with my code inside ToDoItems.js?
ToDoItems.js
import React, { Component } from 'react';
class Kir extends Component {
state = {
todos: [
{
id: 1,
text: 'Take out the trash',
},
{
id: 2,
text: 'Grocery shopping',
},
{
id: 3,
text: 'Clean gecko tank',
}
]
};
render() {
const todoItems = this.state.todos.map((todoItem, index) => {
return (
<div key={index}>
<label>
<input
type="checkbox"
value={todoItem.text}
/>
{todoItem.text}
</label>
</div>
);
});
}
}
export default todoItems;
ToDo.js
import React, { Component } from 'react';
import todoItems from './ToDoItems';
class ToDo extends Component {
render() {
return (
<form>
{todoItems}
</form>
);
}
}
export default ToDo;
💖 💪 🙅 🚩
Kayut
Posted on January 17, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.