Skip to content

Commit

Permalink
fix forwardRef view list
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Mar 12, 2024
1 parent c85a8b8 commit 00fa9c5
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions packages/dataviews/src/view-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import classNames from 'classnames';
/**
* WordPress dependencies
*/
import { forwardRef } from '@wordpress/element';
import { useAsyncList } from '@wordpress/compose';
import {
__experimentalHStack as HStack,
Expand All @@ -17,17 +18,18 @@ import { ENTER, SPACE } from '@wordpress/keycodes';
import { info } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';

export default function ViewList( {
view,
fields,
data,
isLoading,
getItemId,
onSelectionChange,
onDetailsChange,
selection,
deferredRendering,
} ) {
const ViewList = forwardRef( ( props, ref ) => {
const {
view,
fields,
data,
isLoading,
getItemId,
onSelectionChange,
onDetailsChange,
selection,
deferredRendering,
} = props;
const shownData = useAsyncList( data, { step: 3 } );
const usedData = deferredRendering ? shownData : data;
const mediaField = fields.find(
Expand Down Expand Up @@ -68,7 +70,7 @@ export default function ViewList( {
}

return (
<ul className="dataviews-view-list">
<ul className="dataviews-view-list" ref={ ref }>
{ usedData.map( ( item ) => {
return (
<li
Expand Down Expand Up @@ -134,4 +136,5 @@ export default function ViewList( {
} ) }
</ul>
);
}
} );
export default ViewList;

0 comments on commit 00fa9c5

Please sign in to comment.