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

Memoize useSelect callbacks on the header toolbar items #23337

Merged
merged 1 commit into from
Jun 20, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/editor/src/components/editor-history/redo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { redo as redoIcon } from '@wordpress/icons';
import { forwardRef } from '@wordpress/element';

function EditorHistoryRedo( props, ref ) {
const hasRedo = useSelect( ( select ) =>
select( 'core/editor' ).hasEditorRedo()
const hasRedo = useSelect(
( select ) => select( 'core/editor' ).hasEditorRedo(),
[]
);
const { redo } = useDispatch( 'core/editor' );
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/editor/src/components/editor-history/undo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { undo as undoIcon } from '@wordpress/icons';
import { forwardRef } from '@wordpress/element';

function EditorHistoryUndo( props, ref ) {
const hasUndo = useSelect( ( select ) =>
select( 'core/editor' ).hasEditorUndo()
const hasUndo = useSelect(
( select ) => select( 'core/editor' ).hasEditorUndo(),
[]
);
const { undo } = useDispatch( 'core/editor' );
return (
Expand Down
3 changes: 2 additions & 1 deletion packages/editor/src/components/table-of-contents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import TableOfContentsPanel from './panel';

function TableOfContents( { hasOutlineItemsDisabled, ...props }, ref ) {
const hasBlocks = useSelect(
( select ) => !! select( 'core/block-editor' ).getBlockCount()
( select ) => !! select( 'core/block-editor' ).getBlockCount(),
[]
);
return (
<Dropdown
Expand Down
3 changes: 2 additions & 1 deletion packages/editor/src/components/table-of-contents/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function TableOfContentsPanel( { hasOutlineItemsDisabled, onRequestClose } ) {
paragraphCount: getGlobalBlockCount( 'core/paragraph' ),
numberOfBlocks: getGlobalBlockCount(),
};
}
},
[]
);
return (
/*
Expand Down