Skip to content

Commit

Permalink
Block: combine store subscriptions (#56994)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored and artemiomorales committed Jan 4, 2024
1 parent af159ba commit 4e31c42
Show file tree
Hide file tree
Showing 4 changed files with 348 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* WordPress dependencies
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { useContext, useEffect } from '@wordpress/element';
import { useEffect } from '@wordpress/element';

/**
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';
import { BlockListBlockContext } from '../block-list/block-list-block-context';
import { useBlockEditContext } from '../block-edit/context';

/**
* @typedef {'disabled'|'contentOnly'|'default'} BlockEditingMode
Expand Down Expand Up @@ -45,7 +45,7 @@ import { BlockListBlockContext } from '../block-list/block-list-block-context';
* @return {BlockEditingMode} The current editing mode.
*/
export function useBlockEditingMode( mode ) {
const { clientId = '' } = useContext( BlockListBlockContext ) ?? {};
const { clientId = '' } = useBlockEditContext();
const blockEditingMode = useSelect(
( select ) =>
select( blockEditorStore ).getBlockEditingMode( clientId ),
Expand Down
Loading

0 comments on commit 4e31c42

Please sign in to comment.