Page 1 of 1

Wrapper component for DataTable Column component

Posted: 26 Nov 2019, 01:33
by jchau
Is it possible to create a wrapper component for Column component? I tried creating my own component that wraps the PrimeReact DataTable Column component and using my own component inside of a DataTable. However, it never calls my code. Is this because DataTable never actually renders out a Column? Instead, Column is used only for props? I am trying to add certain defaults and helper properties to the Column component to speed up development.

Code: Select all

const DataColumn: React.FC<IDataColumnProps> = (props: IDataColumnProps) => {
    const { style = {}, align, width, ...validProps } = props;
    Object.assign(style, {
        textAlign: align,
        width: width
    });

    return (
        <Column {...validProps} style={style}></Column>
    );
}