Skip to content

Commit

Permalink
the view and processed Data
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmaguitar committed Sep 6, 2024
1 parent b1e18bc commit 3765591
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DataViews } from '@wordpress/dataviews';
import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';
import { getTopicsElementsFormat } from './utils';
import { useState, useMemo } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import './style.scss';

Expand Down Expand Up @@ -91,7 +92,26 @@ const fields = [
];
const App = () => {
// "view" and "setView" definition
const [ view, setView ] = useState( {
type: 'table',
perPage: 10,
layout: defaultLayouts.table.layout,
fields: [
'img_src',
'id',
'alt_description',
'author',
'topics',
'width',
'height',
],
} );

// "processedData" and "paginationInfo" definition
const { data: processedData, paginationInfo } = useMemo( () => {
return filterSortAndPaginate( dataPhotos, view, fields );
}, [ view ] );

// "actions" definition

return (
Expand Down

0 comments on commit 3765591

Please sign in to comment.