You’re getting that notice because your JavaScript code resulted in the following error:
ReferenceError: Cannot access ‘EditComponent’ before initialization
This means you need to register your block after the constants EditComponent and SaveComponent are defined.
// Define the constants first.
const EditComponent = ...;
const SaveComponent = ...;
// Then register your block.
registerBlockType('eternaltwentyfifteen/prevnext', {
// Your args here.
edit: EditComponent,
save: SaveComponent,
});
Alternatively, you can declare them as functions instead.
// Register the block.
registerBlockType('eternaltwentyfifteen/prevnext', {
// Your args here.
edit: EditComponent,
save: SaveComponent,
});
// Functions are hoisted, so EditComponent and SaveComponent are already available
// before registerBlockType() is called.
function EditComponent() {
...
}
function SaveComponent() {
...
}
Further Reading
Excerpts from MDN:
-
constdeclarations can only be accessed after the place of declaration is reached (see temporal dead zone). For this reason,constdeclarations are commonly regarded as non-hoisted.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const#description
-
Functions must be in scope when they are called, but the function declaration can be hoisted (appear below the call in the code).
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#calling_functions
See also Understanding JavaScript Function Declarations: ‘function’ vs ‘const’ on DEV.to.