Bird
0
0

Identify the error in this block registration code:

medium📝 Debug Q14 of 15
Wordpress - Shortcodes and Blocks
Identify the error in this block registration code:
registerBlockType('myplugin/test', {
  edit() {
    return <p>Edit Block</p>
  },
  save() {
    return <p>Save Block</p>
  }
});
AJSX syntax used without React or Babel setup
BBlock name missing namespace
CMissing semicolons after return statements
Dedit and save functions must be arrow functions
Step-by-Step Solution
Solution:
  1. Step 1: Check the syntax used in edit and save functions

    The code uses JSX syntax like <p>Edit Block</p> directly, which requires React and Babel setup to compile.
  2. Step 2: Identify environment requirements

    If JSX is used without proper setup, this code will cause syntax errors. The code should use wp.element.createElement or have JSX compiled.
  3. Final Answer:

    JSX syntax used without React or Babel setup -> Option A
  4. Quick Check:

    JSX needs compilation = JSX syntax used without React or Babel setup [OK]
Quick Trick: JSX needs React/Babel; otherwise use createElement [OK]
Common Mistakes:
  • Assuming JSX works without setup
  • Thinking semicolons are mandatory after return
  • Believing edit/save must be arrow functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes