I've defined my column metadata for griddle-react
like so:
const cols = [
{"columnName": 'id', "displayName": "ID", "visible": false, "order": 1},
{"columnName": 'name', "displayName": "Name", "order": 2, "customComponent": BrandNameLink},
{"columnName": 'description', "displayName": "Description", "order": 3},
{"columnName": 'dateCreated', "displayName": "Date Created", "visible": true, "order": 4, "customComponent": DateComponent},
{"columnName": 'lastUpdated', "displayName": "Last Updated", "visible": true, "order": 5, "customComponent": DateComponent},
];
for the name
, dateCreated
and lastUpdated
I want to pass in additional props to these custom components. For example, my DateComponent
looks like so:
import React from 'react';
import Time from 'react-time';
const DateComponent = (props) => {
return (<Time value={props.rowData.dateCreated} format="MM-DD-YYYY" />);
}
export default DateComponent;
But I would like to be able to tell it to use dateCreated
or lastUpdated
from the rowData
vs making 2 nearly identical components (1 for each date property).