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

Simplify the code #255

Closed
dingo-d opened this issue Sep 1, 2022 · 1 comment · Fixed by #256
Closed

Simplify the code #255

dingo-d opened this issue Sep 1, 2022 · 1 comment · Fixed by #256
Assignees
Labels
improvement Small improvement fixes, either readability or performance improvements

Comments

@dingo-d
Copy link
Collaborator

dingo-d commented Sep 1, 2022

Was checking out how to see if I have inner blocks, so I stumbled upon the code here

// Check if form selector has inner blocks.
const hasInnerBlocksCheck = useSelect((select) => {
const { innerBlocks } = select('core/block-editor').getBlock(clientId);
if (!innerBlocks.length) {
return false;
}
return true;
});

and my editor suggested a simplification of this part to:

	// Check if form selector has inner blocks.
	const hasInnerBlocksCheck = useSelect((select) => {
		const { innerBlocks } = select('core/block-editor').getBlock(clientId);

		return innerBlocks.length;
	});
@dingo-d dingo-d added the improvement Small improvement fixes, either readability or performance improvements label Sep 1, 2022
@iruzevic
Copy link
Member

iruzevic commented Sep 1, 2022

tnx added, it will be on the next PR

@iruzevic iruzevic linked a pull request Sep 2, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Small improvement fixes, either readability or performance improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants