-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Making Datagrid Generic #10595
Comments
Thank you for the report. However, to me, this is not a regression. I went back to version 5.3.4 and had the same errors. I believe passing a generic type to It would be nice to do it though, so I'll label this issue as enhancement request. Would you like to open a PR to support this? |
Can you assign this issue to me if that's possible ? |
Hi @dhfra21, we don't assign issues. You can just open a PR for us to review 👍 |
@djhi can you help me with the pr, the solution was not as good as I imagined, but I am dedicated to fixing it |
@djhi investigating here I was able to find more inputs to help The error happened after this 76ddad3 commit below that shared the rowClick function and added the generic type for it. If we define the function as before, we solve the problem I'm having. To work around this before an RA update, the type can be overridden: declare module 'react-admin' {
type RowClickFunction<RecordType extends RaRecord = RaRecord> = (
id: Identifier,
resource: string,
record: RecordType,
) => string | false | Promise<string | false>
interface DatagridCustomProps<RecordType extends RaRecord = RaRecord>
extends Omit<DatagridProps<RecordType>, 'rowClick'> {
rowClick?: string | false | RowClickFunction<RecordType>
}
function Datagrid<RecordType extends RaRecord = RaRecord>(props: DatagridCustomProps<RecordType>): JSX.Element
} |
What you were expecting:
I'm getting this error
And I believe it is bad practice to continue with the unkown for this case
What happened instead:
I'm not able to pass a generic to the datagrid so that it changes the record in rowClick and other functions.
Steps to reproduce:
Related code:
Datagrid.tsx / DatagridProps
Other information:
Environment
The text was updated successfully, but these errors were encountered: