Open
Description
Here in the useBlockProps usage example, the snippet is missing braces, which generates an error in the console.
Issue Description
The current code snippet using useBlockProps
is:
const blockProps = useBlockProps(
className: 'my-custom-class',
style: {
color: '#222222',
backgroundColor: '#eeeeee'
}
)
The useBlockProps
hook expects an object as a parameter. The snippet is missing braces, so the correct version should be:
const blockProps = useBlockProps( {
className: 'my-custom-class',
style: {
color: '#222222',
backgroundColor: '#eeeeee'
}
} )
For reference, another snippet on this doc correctly demonstrates the usage of the useBlockProps
hook.
URL of the Page with the Issue
Section of Page with the issue
The section is: useBlockProps
Why is this a problem?
The snippet throws an error for missing braces.
Suggested Fix
Pass parameters in the useblockprops
hook as an object.
I've created a pull request with the solutions: WordPress/gutenberg#61839
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment