-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Table cell type error #82
Comments
Actually I think this issue is caused because I upgraded to React 18. My solution specify the type of entry[field] as any.
Seems to do the trick but I'm sure theres a more proper way of solving this. |
Yeah, I'm a TS newbie as well, and I was facing the same issue, I managed to fix/hack it by changing, this: export const Table = <Entry extends { id: string }>({ data, columns }: TableProps<Entry>) => { To this: export const Table = <Entry extends Record<string, any> & { id: string }>({ data, columns }: TableProps<Entry>) => { |
Another possible solutions-
|
I'm getting the following error on the table component.
ERROR in src/components/Elements/Table/Table.tsx:57:25 TS2322: Type 'Element | Entry[keyof Entry]' is not assignable to type 'ReactNode'. Type 'Entry[keyof Entry]' is not assignable to type 'ReactNode'. Type 'Entry[string] | Entry[number] | Entry[symbol]' is not assignable to type 'ReactNode'. Type 'Entry[string]' is not assignable to type 'ReactNode'. Type 'Entry[string]' is not assignable to type 'ReactPortal'. Type 'Entry[keyof Entry]' is not assignable to type 'ReactPortal'. Type 'Entry[string] | Entry[number] | Entry[symbol]' is not assignable to type 'ReactPortal'. Type 'Entry[string]' is not assignable to type 'ReactPortal'.
I presume there is a problem with the TableColumn type definition.
type TableColumn<Entry> = { title: string; field: keyof Entry; Cell?({ entry }: { entry: Entry }): React.ReactElement; };
I'm only just learning TS and haven't been able to figure out what the Cell type definition is doing. An explanation on this would be greatly appreciated!
The text was updated successfully, but these errors were encountered: