I'm currently learning if else statement in React,
So i want the button in the table to appear if the variable "step" is set to 1, other than that the button (and the row) wont appear. What method is the best to implement this if else?
function DeletableGroupRow({
student,
hasDeleteButton = false,
onDeleteStudent,
step,
}) {
DeletableGroupRow.propTypes = {
student: PropTypes.object.isRequired,
hasDeleteButton: PropTypes.bool,
onDeleteStudent: PropTypes.func.isRequired,
};
const handleDeleteClick = () => {
onDeleteStudent(student.id);
};
return (
<tr>
<td>{student.nim}</td>
<td>{student.name}</td>
<td>{student.class}</td>
<td>{student.peminatan.abbrev}</td>
// if the variable "step" is set to 1 then this td appears
<td>
<button
type="button"
className="btn btn-default"
onClick={handleDeleteClick}
disabled={!hasDeleteButton}
>
Hapus
</button>
</td>
//
</tr>
);
}