@@ -11,7 +11,6 @@ import { forwardRef, useMemo } from '@wordpress/element';
1111import { useSelect } from '@wordpress/data' ;
1212import {
1313 getBlockSupport ,
14- getBlockType ,
1514 store as blocksStore ,
1615 __unstableGetInnerBlocksProps as getInnerBlocksProps ,
1716} from '@wordpress/blocks' ;
@@ -23,7 +22,7 @@ import ButtonBlockAppender from './button-block-appender';
2322import DefaultBlockAppender from './default-block-appender' ;
2423import useNestedSettingsUpdate from './use-nested-settings-update' ;
2524import useInnerBlockTemplateSync from './use-inner-block-template-sync' ;
26- import getBlockContext from './get -block-context' ;
25+ import useBlockContext from './use -block-context' ;
2726import { BlockListItems } from '../block-list' ;
2827import { BlockContextProvider } from '../block-context' ;
2928import { useBlockEditContext } from '../block-edit/context' ;
@@ -75,28 +74,10 @@ function UncontrolledInnerBlocks( props ) {
7574 templateInsertUpdatesSelection
7675 ) ;
7776
78- const { context, name } = useSelect (
77+ const context = useBlockContext ( clientId ) ;
78+ const name = useSelect (
7979 ( select ) => {
80- const block = select ( blockEditorStore ) . getBlock ( clientId ) ;
81-
82- // This check is here to avoid the Redux zombie bug where a child subscription
83- // is called before a parent, causing potential JS errors when the child has been removed.
84- if ( ! block ) {
85- return { } ;
86- }
87-
88- const blockType = getBlockType ( block . name ) ;
89-
90- if (
91- Object . keys ( blockType ?. providesContext ?? { } ) . length === 0
92- ) {
93- return { name : block . name } ;
94- }
95-
96- return {
97- context : getBlockContext ( block . attributes , blockType ) ,
98- name : block . name ,
99- } ;
80+ return select ( blockEditorStore ) . getBlock ( clientId ) ?. name ;
10081 } ,
10182 [ clientId ]
10283 ) ;
0 commit comments