In my application I have table that has been rendered using React JS. The Requirement is to hide the enter column (both th and td) when the button in each column is clicked. I am not sure how to achieve it.
https://stackblitz.com/edit/react-cjzst8
import React, { Component } from 'react';
import { render } from 'react-dom';
var tableData = [
{
"_id": "5de8d7",
"name": "Oneill Chang",
"company": "TINGLES",
"email": "[email protected]",
"phone": "+1 (826) 583-3110"
},
{
"_id": "5de8d5",
"name": "Rogers Davis",
"company": "ENTALITY",
"email": "[email protected]",
"phone": "+1 (918) 571-2672"
},
{
"_id": "8d05243",
"name": "Barlow Alford",
"company": "BRISTO",
"email": "[email protected]",
"phone": "+1 (855) 527-2874"
},
{
"_id": "6f5b6",
"name": "Hopper Cote",
"company": "BEZAL",
"email": "[email protected]",
"phone": "+1 (968) 565-2872"
}
]
class App extends Component {
constructor() {
super();
this.state = {
data:[]
};
}
componentDidMount(){
this.setState({
data:tableData
})
}
render() {
return (
<table className="table" >
<thead>
<tr>
<td> Id <br/> <button> Hide </button> </td>
<td> Name <br/> <button> Hide </button> </td>
<td> Company <br/> <button> Hide </button> </td>
<td> Email <br/> <button> Hide </button> </td>
<td> Phone <br/> <button> Hide </button> </td>
</tr>
</thead>
<tbody>
{this.state.data.map((item,index)=>{
return(
<tr>
<td> {item._id} </td>
<td> {item.name} </td>
<td> {item.company} </td>
<td> {item.email} </td>
<td> {item.phone} </td>
</tr>
)
})}
</tbody>
</table>
);
}
}
render(<App />, document.getElementById('root'));
hide the enter column?