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
[v8] getValue should return a null value for nested keys #4499
Comments
I'm just trying to migrate from v7 and ended up coming across this on v8.7.0. It seems to me the table shouldn't throw an error if value is undefined on the data level (not when rendering it, as React doesn't allow to render an undefined value). This was introduced here: |
I have some nested keys that are sometimes returned as undefined or null from my backend, both of which mean different things about that data, so it would not be great if it was always converted to a |
I really want to use this table extension in my vue project. But I have optional returned parameters in my response from server. So I know that there are deeply nested keys which are undefined / does not exists. Is there any possibility to at least disable the warning messages? Will it also work in production? I would be very happy about an answer, otherwise I unfortunately can not use the extension. Can I ask kindly for your opinion @tannerlinsley? |
I have a work around that might help people
|
Describe the bug
The issue is related to this issue: #4320 (comment)
The prior issue was solved by introducing an elaborate error message for undefined nested keys.
In a case, where some rows might have nested keys and others not, it is possible to catch the error of getValue, it is not nice though. Furthermore, this also adds up to other functions like getRowModel, when filters are used. So each function would need to get a try catch.
The alternative approach would be, to create an entry for each nested key in each row. But it can be annoying for nested objects.
I would propose returning a null value, if the nested key is missing.
table/packages/table-core/src/core/column.ts
Line 58 in 7b92953
Your minimal, reproducible example
https://codesandbox.io/s/dark-sky-pwysi7?file=/src/main.tsx
Steps to reproduce
See codesandbox.
Toggle line 29 comment in main.tsx and see how it works/fails.
I am not using columnHelper, since my use case has a nested Record<string, any> object without proper typing.
Expected behavior
If getValue() returns null for nested keys, it won´t fail.
How often does this bug happen?
No response
Screenshots or Videos
No response
Platform
react-table version
v.8.5.22
TypeScript version
No response
Additional context
I am not fully sure, if getValue() should return null or undefined, since I am not familiar enough with tanstack table and possible side effects.
Terms & Code of Conduct
The text was updated successfully, but these errors were encountered: