-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functional Components (Hooks) - Editable options #1325
Comments
I resolved the scenario with a some adjustments to my first code... but I still required your POV to know if this solution is the best approach: https://codesandbox.io/s/materialtableui-cpxz6 ...seems it's working now, basically, I created a state that has the data array, the resolve function of the promise, and a date (Just used as log):
And to update and resolve the promise I use an effect:
The editable functions:
I used a destruct to use the data array of the state into the Material Table:
...this approach is the best? Or have some flaws that I not see... Thanks! |
i used the code above that @mbv401920150 provided as an example to solve my onRowUpdate issue. Thank you so much. |
Hi, I used the code you provided @mbv401920150 and it worked fine, but when I changed ir to receive data from props it stoped updating.
Originally I had a callback to a parent component that handles the data request and logic. That callback changed the state in the parent, that was then passed as props to the table. But I removed all of that, trying simply to take data from props, and then updating the state within the table component. I print the data variable to the console before rendering, and it contains the new values, except for a tableData element.
console output:
initial data printed to console:
Any Ideas? |
@DanielFerszt - add a key to the table that is randomly set to force the refresh:
|
Thanks, I'll try that. I solved the issue by adding a second state for the columns and refreshing that with every edit too... That forced the table to refresh. |
I have also set the tableRef and called onQueryChange to force a refresh as well on row edits. |
Hey, Can you please guys @TroySchmidt or @DanielFerszt provide a working exemple of your guys solution. I'm trying to move my project to react hooks and I'm not able to have my props containing the data of my table, passed down to that material-table. I tried the refreshed keys already trick, but didn't make any difference.
|
Sure, here is a link to my question in stackOverflow where someone answered very well. He even explains a little more in the comments at my request. Let me know it you need more help! |
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. |
I'm checking the Editable option, but only has documentation related of React Components (Classes).
I need help to know how to apply the same feature with a Functional Component (Using Hooks)...
https://material-table.com/#/docs/features/editable
I cannot figure out how to update a state and execute the function
resolve()
.Does somebody have the same problem?
Find the code right here
https://codesandbox.io/s/materialtableui-b35v3
The text was updated successfully, but these errors were encountered: