diff --git a/packages/edit-site/src/components/dataviews/dataviews.js b/packages/edit-site/src/components/dataviews/dataviews.js
index 755ce8a2ea348..da0d1735b6a3a 100644
--- a/packages/edit-site/src/components/dataviews/dataviews.js
+++ b/packages/edit-site/src/components/dataviews/dataviews.js
@@ -5,6 +5,7 @@ import {
__experimentalVStack as VStack,
__experimentalHStack as HStack,
} from '@wordpress/components';
+import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
@@ -25,6 +26,12 @@ export default function DataViews( {
paginationInfo,
} ) {
const ViewComponent = view.type === 'list' ? ViewList : ViewGrid;
+ const _fields = useMemo( () => {
+ return fields.map( ( field ) => ( {
+ ...field,
+ render: field.render || field.accessorFn,
+ } ) );
+ }, [ fields ] );
return (
@@ -37,7 +44,7 @@ export default function DataViews( {
/>
- { ( mediaField &&
- mediaField.render( { item, view } ) ) || (
+ { mediaField?.render( item, view ) || (
{ visibleFields.map( ( field ) => (
- { field.render
- ? field.render( { item, view } )
- : field.accessorFn( item ) }
+ { field.render( item, view ) }
) ) }
diff --git a/packages/edit-site/src/components/dataviews/view-list.js b/packages/edit-site/src/components/dataviews/view-list.js
index d675720c86f83..ba7e6e3032889 100644
--- a/packages/edit-site/src/components/dataviews/view-list.js
+++ b/packages/edit-site/src/components/dataviews/view-list.js
@@ -145,18 +145,11 @@ function ViewList( {
paginationInfo,
} ) {
const columns = useMemo( () => {
- const _columns = [
- ...fields.map( ( field ) => {
- const column = { ...field };
- delete column.render;
- column.cell = ( props ) => {
- return field.render
- ? field.render( { item: props.row.original, view } )
- : field.accessorFn( props.row.original );
- };
- return column;
- } ),
- ];
+ const _columns = fields.map( ( field ) => {
+ const { render, ...column } = field;
+ column.cell = ( props ) => render( props.row.original, view );
+ return column;
+ } );
if ( actions?.length ) {
_columns.push( {
header: { __( 'Actions' ) },
diff --git a/packages/edit-site/src/components/page-pages/index.js b/packages/edit-site/src/components/page-pages/index.js
index 602d14b8ad2e3..502e03f49b3e8 100644
--- a/packages/edit-site/src/components/page-pages/index.js
+++ b/packages/edit-site/src/components/page-pages/index.js
@@ -89,7 +89,7 @@ export default function PagePages() {
id: 'featured-image',
header: __( 'Featured Image' ),
accessorFn: ( page ) => page.featured_media,
- render: ( { item, view: currentView } ) =>
+ render: ( item, currentView ) =>
!! item.featured_media ? (
page.title?.rendered || page.slug,
- render: ( { item: page } ) => {
+ render: ( page ) => {
return (
@@ -134,7 +134,7 @@ export default function PagePages() {
header: __( 'Author' ),
id: 'author',
accessorFn: ( page ) => page._embedded?.author[ 0 ]?.name,
- render: ( { item } ) => {
+ render: ( item ) => {
const author = item._embedded?.author[ 0 ];
return (
@@ -153,7 +153,7 @@ export default function PagePages() {
{
header: 'Date',
id: 'date',
- render: ( { item } ) => {
+ render: ( item ) => {
const formattedDate = dateI18n(
getSettings().formats.datetimeAbbreviated,
getDate( item.date )