[ SYSTEM ]: Linux wordpress 6.1.0-44-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
[ SERVER ]: Apache/2.4.66 (Debian) | PHP: 8.2.30
[ USER ]: www-data | IP: 172.19.30.54
GEFORCE FILE MANAGER
/
var
/
www
/
html
/
wordpress
/
wp-content
/
plugins
/
presto-player
/
src
/
admin
/
analytics
/
hocs
/
UPLOAD:
NAME
SIZE
QUICK PERMS
ACTIONS
📄 withDataList.js
2,195 B
SET
[ EDIT ]
|
[ DEL ]
📄 withStat.js
1,408 B
SET
[ EDIT ]
|
[ DEL ]
DELETE SELECTED
[ CLOSE ]
EDIT: withStat.js
/** * WordPress dependencies */ const { apiFetch } = wp; const { useState } = wp.element; const { createHigherOrderComponent } = wp.compose; /** * Higher order component factory * * @return {Function} The higher order component. */ export default () => createHigherOrderComponent( (WrappedComponent) => (props) => { const [loading, setLoading] = useState(false); const [stat, setStat] = useState([]); const [error, setError] = useState(""); // fetch data // we could also abstract this function to make it reusable // or do a higher order component const fetchData = async ({ endpoint, params = {} }) => { setLoading(true); let responseData; try { responseData = await apiFetch({ path: wp.url.addQueryArgs(endpoint, { ...params, }), }); setStat(responseData); } catch (e) { console.error(e); if (e?.message) { setError(e.message); } } finally { setLoading(false); } }; return ( <WrappedComponent loading={loading} setLoading={setLoading} fetchData={fetchData} stat={stat} setStat={setStat} error={error} setError={setError} {...props} /> ); }, "withStat" );