Passing custom data to a Cell component #3487
Answered
by
xavier-taylor
brandondurham
asked this question in
Q&A
-
I need to pass a My data and columns look something like this: import { Link } from '../Link';
export const data = [
{
date: 'March 17, 2021',
orderNumber: 'c150be5f-195a-4e66-bf1e-55af785628cc',
},
{
date: 'March 18, 2021',
orderNumber: '1c2bef06-f57f-4d99-b0fc-f072ca91bff0',
},
{
date: 'March 19, 2021',
orderNumber: 'e49425d4-2f28-4f48-b8d9-85e859ed6ce5',
},
];
export const columns = [
{
accessor: 'date',
Header: 'Date',
},
{
accessor: 'orderNumber',
Cell: props => {
console.log(props);
return <Link href="/">{ props.value }</Link>;
},
Header: 'Amount',
},
]; When using custom components in I know I can do something like this, but I don’t expect this is the recommended way: import { Link } from '../Link';
export const data = [
{
date: 'March 17, 2021',
href: '/order/something',
orderNumber: 'c150be5f-195a-4e66-bf1e-55af785628cc',
},
{
date: 'March 18, 2021',
href: '/order/nothing',
orderNumber: '1c2bef06-f57f-4d99-b0fc-f072ca91bff0',
},
{
date: 'March 19, 2021',
href: '/order/everything',
orderNumber: 'e49425d4-2f28-4f48-b8d9-85e859ed6ce5',
},
];
export const columns = [
{
accessor: 'date',
Header: 'Date',
},
{
accessor: 'orderNumber',
Cell: props => {
return <Link href={ props?.cell?.row?.original?.href }>{ props.value }</Link>;
},
Header: 'Amount',
},
]; |
Beta Was this translation helpful? Give feedback.
Answered by
xavier-taylor
Oct 3, 2021
Replies: 1 comment 1 reply
-
Try this - I am doing something similar in my app, it works.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
brandondurham
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this - I am doing something similar in my app, it works.