Skip to content

Commit

Permalink
Refactor to use applyFiltersSync
Browse files Browse the repository at this point in the history
  • Loading branch information
donnapep committed Nov 6, 2024
1 parent 8b198bf commit 2dd4a50
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions assets/admin/students/student-action-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* WordPress dependencies
*/
import { DropdownMenu } from '@wordpress/components';
import { render, useState } from '@wordpress/element';
import { render, useEffect, useState } from '@wordpress/element';
import { moreVertical } from '@wordpress/icons';
import { applyFilters } from '@wordpress/hooks';
import { applyFilters, applyFiltersAsync } from '@wordpress/hooks';
import { __ } from '@wordpress/i18n';

/**
Expand Down Expand Up @@ -70,12 +70,20 @@ export const StudentActionMenu = ( {
*
* @return {Array} Filtered controls.
*/
applyFilters(
'senseiStudentActionMenuControls',
defaultControls,
setAction,
setModalOpen
);
useEffect( () => {
async function getMenuControls() {
const response = await applyFiltersAsync(
'senseiStudentActionMenuControls',
defaultControls,
setAction,
setModalOpen
);

setControls( response );
}

getMenuControls();
}, [ defaultControls ] );

const addToCourse = () => {
setAction( 'add' );
Expand Down

0 comments on commit 2dd4a50

Please sign in to comment.