I am currently working on a linktree using the Datagrid Component from MaterialUI. Data can be displayed, but when I try to add a new entry there occurs the problem that the content remains the same. The state changes, but without rendering the new data.
const columns = [
{field: 'date', headerName: 'Date', width: 120},
{
field: 'videoUrl',
headerName: 'Video URL',
width: 430,
renderCell: (params) =>
<a href={(params.value)}>{params.value}</a>
},
{field: 'description', headerName: 'Description', width: 130},
];
class Linktree extends React.Component {
this.state = {
newLink: "",
newDescription: "",
}
}
handleAddNewLink(newLink, description) {
let obj = this.state.linksData
let newEntry = {id: this.state.linksData.length+1, postDate: today, videoUrl: newLink, description: description}
obj.push(newEntry)
this.setState({linksData: obj})
}
render (){
return (
<div>
<div style={{height: 400, width: '100%', backgroundColor: "white"}}>
<DataGrid rows={!this.state.loading ? this.state.linksData : []} columns={columns} pageSize={5} hideFooterSelectedRowCount/>
</div>
</div>
);
}}