Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
optometrists
/
cache
/
cache
/
cache
/
.wp-cli
/
wp-content
/
plugins
/
woocommerce
/
packages
/
woocommerce-blocks
/
assets
/
js
/
base
/
components
/
product-list
:
container.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
/** * External dependencies */ import { useState, useEffect } from '@wordpress/element'; import PropTypes from 'prop-types'; /** * Internal dependencies */ import ProductList from './product-list'; const ProductListContainer = ( { attributes, hideOutOfStockItems = false, } ) => { const [ currentPage, setPage ] = useState( 1 ); const [ currentSort, setSort ] = useState( attributes.orderby ); useEffect( () => { // if default sort is changed in editor setSort( attributes.orderby ); }, [ attributes.orderby ] ); const onPageChange = ( newPage ) => { setPage( newPage ); }; const onSortChange = ( event ) => { const newSortValue = event.target.value; setSort( newSortValue ); setPage( 1 ); }; return ( <ProductList attributes={ attributes } hideOutOfStockItems={ hideOutOfStockItems } currentPage={ currentPage } onPageChange={ onPageChange } onSortChange={ onSortChange } sortValue={ currentSort } /> ); }; ProductListContainer.propTypes = { attributes: PropTypes.object.isRequired, hideOutOfStockItems: PropTypes.bool, }; export default ProductListContainer;