I want to get extensible row functionality for a table. Suppose we have a table with task names and task complexity. When you click on one task, the task description is shown below. I am trying to do this with ReactJS (in the render method):
if (selectedTask === task.id) {
return [
<tr>
<td>{task.name}</td>
<td>{task.complexity}</td>
</tr>,
<tr>
<td colSpan="2">{task.description}</td>
</tr>
];
} else {
return <tr>
<td>{task.name}</td>
<td>{task.complexity}</td>
</tr>;
}
And it does not work. It says:
A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object
I also tried to wrap 2 lines in a div, but I'm wrong. Please suggest the right solution.
source
share