Bird
0
0

Why does this Gutenberg block registration code produce an error?

medium📝 Debug Q7 of 15
Wordpress - Content Management
Why does this Gutenberg block registration code produce an error?
registerBlockType('my-plugin/block', { edit: () => { <p>Hello</p> }, save: () => <p>Hello</p> });
AThe edit function lacks a return statement inside the curly braces.
BThe save function cannot return JSX elements.
CBlock names cannot contain hyphens.
DThe registerBlockType function requires a third argument.
Step-by-Step Solution
Solution:
  1. Step 1: Check edit function syntax

    Using curly braces without return means nothing is returned.
  2. Step 2: Understand arrow function behavior

    Arrow functions with braces need explicit return statements.
  3. Final Answer:

    The edit function lacks a return statement inside the curly braces. -> Option A
  4. Quick Check:

    Arrow functions with braces require return [OK]
Quick Trick: Arrow functions with braces need return [OK]
Common Mistakes:
  • Thinking save cannot return JSX
  • Believing block names disallow hyphens
  • Assuming registerBlockType needs three arguments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes