Bird
0
0

What is wrong with this block registration snippet?

medium📝 Debug Q7 of 15
Wordpress - Shortcodes and Blocks
What is wrong with this block registration snippet?
registerBlockType('myplugin/block', { title: 'Block', edit: () => 'Edit', save: () => 'Save' });
ABlock name must not contain slashes
BEdit and save functions must return JSX elements, not strings
CTitle property must be a function
DNo errors, this code is valid
Step-by-Step Solution
Solution:
  1. Step 1: Review edit and save function returns

    In block registration, edit and save must return valid JSX elements, not plain strings.
  2. Step 2: Identify the error

    Returning strings like 'Edit' or 'Save' will cause rendering issues in the editor.
  3. Final Answer:

    Edit and save functions must return JSX elements, not strings -> Option B
  4. Quick Check:

    edit/save must return JSX, not strings [OK]
Quick Trick: edit/save return JSX elements, not plain text [OK]
Common Mistakes:
  • Returning plain strings in edit/save
  • Misunderstanding block name format
  • Thinking title must be a function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes