Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block: combine store subscriptions #56994

Merged
merged 10 commits into from Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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