From 2dd4a50596fc76c4a28d39c9001573aaf49ab1b5 Mon Sep 17 00:00:00 2001 From: Donna Peplinskie Date: Wed, 6 Nov 2024 15:07:43 -0500 Subject: [PATCH] Refactor to use applyFiltersSync --- .../students/student-action-menu/index.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/assets/admin/students/student-action-menu/index.js b/assets/admin/students/student-action-menu/index.js index 88bef521b3..0dd56eda8e 100644 --- a/assets/admin/students/student-action-menu/index.js +++ b/assets/admin/students/student-action-menu/index.js @@ -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'; /** @@ -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' );