Closed Bryceacampbell closed 3 years ago
FWIW I'm having the same problem. In my situation I'm using mobx
const store = useLocalStore(() => ({
data: [
{id: 1, name: 'aaa'},
{id: 2, name: 'bbb'}
]
}));
return useObserver(() => (
<div>
<button onClick={() => {
store.data[0].name = 'zzz';
}}>Test</button>
<MaterialTable
data={store.data}
columns={[
{title: 'Id', field: 'id'},
{title: 'Name', field: 'name'},
]}
/>
</div>
));
If I can figure it out I'll let you know
I am having the same issue, the new value indeed got passed to the table but table did not update it unless a manual click on the table. Here is the link of my issue: https://github.com/mbrn/material-table/issues/2693
I resolved my issue by updating the value inside onClick. Here is what I did:
const [data, setData] = useState(props.entryList);
.....
actions={[
{
icon: 'Charge',
tooltip: 'Charge User',
onClick: (event, rowData) => {
// setData here to force table update using new value
setTimeout(() => {
setData([rowData]);
}, 1000);
}
}
]}
Hope this helps.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.
if this still a stand issue for some just use refetch from useQuery() to update table data after an edit or create
Hello, I am running into an issue and could use some help. I am using apollo client to fetch some lead data and pass it into the material table (this works great). I have a side-drawer that opens on row click with the dynamic row data and I have a form inside the side-drawer that allows a user to update the row data. However, material-table doesn't render the updates until I refresh the page.
Leads.js is the parent component that fetches the leads, and sets the leads into state using react hooks.
LeadsTable.js is where I take in the leads as props and pass it into material-table. There is an onRowClick event that opens a side drawer with dynamic lead details.
LeadDrawer.js has navigation tabs and the update form lives inside the overview tab here. You can see I am passing in the setLeads and leads props
and finally inside the AddAdditionalInfo form I have a handle submit function that runs an apollo mutation to update the lead in the DB and setLeads to the new updated leads
Summary: I am updating the leads state by calling setLeads and material-table isn't rendering the changes unless I refresh the page. I am not assuming it is a problem with material table, I'm just looking for some help or maybe a second eye. I have been stuck on this little problem for far too long. Maybe I just need a different approach... Any ideas or help would be much appreciated.