Closed EBruchet closed 4 years ago
The solution right now is setting data
to some empty value for the expandable component and then check for this empty value in the component itself:
export interface Props {
data: SomeType;
}
export const ExampleExpandedRowComponent = (props: Props) => {
if (!props.data) {
return null
}
return <div>{props.data.someProperty}</div>;
};
...
<DataTable
columns={SOME_ARRAY}
data={SOME_DATA}
expandableRows
expandableRowsComponent={<ExampleExpandedRowComponent data={null} />}
/>
But In the future, I would also like to see an option to give React.ReactNode
(or preact
's VNode
) as acceptable parameter to expandableRowsComponent
, like you mentioned:
<DataTable
expandableRowsComponent={(t: T) => <ExampleExpandedRowComponent data={t}/>}
{...otherProps}
/>
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.
Feature Check list
Is your feature request related to a problem? Please describe
In using
typescript
, I'm unable to pass a component that takes a singleprop
of typeT
toexpandableRowsComponent
prop
when columns are of typeIDataTableColumn<T>[]
.The above returns the following error:
TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & Props'. Type '{}' is not assignable to type 'Props'.
Describe the solution you'd like
The ability to pass a function with explicit typing on its arguments as follows:
Describe alternatives you've considered
I have attempted the above solution I've suggested above and have been met with the following error:
Warning: Failed prop type: Invalid prop 'children' supplied to 'ExpanderRow'. in ExpanderRow
It's very likely I'm missing a simple resolution to this TS-related issue, but would appreciate guidance nonetheless. Thank you.