wp-each "Cannot access 'state' before initialization" #69266
Labels
[Feature] Interactivity API
API to add frontend interactivity to blocks.
[Type] Bug
An existing feature does not function as intended
Description
I've updated gutenberg from a v18... to the current v20.2.0 and it seems something has changed with how the state is initialised before directives are parsed.
My wp-each directive referencing a state derived getter wasn't a problem before. Now when the wp-each directive is parsed and calls a getter on the state that uses the state variable I'm getting the error: "ReferenceError: Cannot access 'state' before initialization"
I had to wrap the first access to the state in the getter with a try catch to find out this was the problem.
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Example:
view.js state getter snippet
render.php snippet
Environment info
Wordpress 6.7.2
Gutenberg 20.2.0
Custom theme
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
The text was updated successfully, but these errors were encountered: