From 3765591f9d3b83277c2f8fb89498beea64b5fcbb Mon Sep 17 00:00:00 2001 From: JuanMa Garrido Date: Thu, 22 Aug 2024 13:00:29 +0100 Subject: [PATCH] the view and processed Data --- src/App.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index 859e610..eef35fd 100644 --- a/src/App.js +++ b/src/App.js @@ -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'; @@ -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 (