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 committed Dec 13, 2023
1 parent fdea164 commit 80281d1
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

1 comment on commit 80281d1

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 80281d1.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7201443827
📝 Reported issues:

Please sign in to comment.