From 886662ec6b0160a9519f11e07bd9243fd808a62f Mon Sep 17 00:00:00 2001
From: George Mamadashvili
Date: Fri, 6 Dec 2024 13:58:44 +0400
Subject: [PATCH] Block Editor: Remove 'React.Children' legacy API in 'Warning'
component (#67675)
Co-authored-by: Mamaduka
Co-authored-by: youknowriad
---
packages/block-editor/src/components/warning/index.js | 7 +++----
packages/block-editor/src/components/warning/test/index.js | 4 +++-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/packages/block-editor/src/components/warning/index.js b/packages/block-editor/src/components/warning/index.js
index 8b6279bef6044d..17a014107b43af 100644
--- a/packages/block-editor/src/components/warning/index.js
+++ b/packages/block-editor/src/components/warning/index.js
@@ -6,7 +6,6 @@ import clsx from 'clsx';
/**
* WordPress dependencies
*/
-import { Children } from '@wordpress/element';
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { moreVertical } from '@wordpress/icons';
@@ -20,10 +19,10 @@ function Warning( { className, actions, children, secondaryActions } ) {
{ children }
- { ( Children.count( actions ) > 0 || secondaryActions ) && (
+ { ( actions?.length > 0 || secondaryActions ) && (
- { Children.count( actions ) > 0 &&
- Children.map( actions, ( action, i ) => (
+ { actions?.length > 0 &&
+ actions.map( ( action, i ) => (
{
it( 'should show primary actions', () => {
render(
- Click me }>Message
+ Click me ] }>
+ Message
+
);
expect(