Can't Get @wordpress/scripts to Render JSX on public front-end (Worked with version 27.x.x) #69034
-
Hello everyone, I'm using @wordpress/scripts for a classic theme. It's worked wonderfully for me for years, as it has built in webpack aliases for react and WordPress's copy of react ('wp-element') and I've used it to render React components on the public front-end. Always had great luck. I've isolated my tests, since updating beyond version 27.x.x to anything newer, including today's current version, I cannot seem to render any React components on the front-end, and get this message in the browser's console: ""Uncaught TypeError: Cannot read properties of undefined (reading 'jsx')" Key files: My index.js With no other changes to my code, just jumping @wordpress/scripts beyond 27.x.x causes the issue. Previously no further configuration was required, am I missing something in terms of setting up the @wordpress/scripts to work? Thank you for any pointers in the right direction. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
To anyone who might be running into this same issue, I found my solution. In functions.php, when I'm enqueuing my JS file, in addition to 'wp-element' I also needed to include 'react-jsx-runtime' as a dependency as well. Happy coding to you all 🎉 |
Beta Was this translation helpful? Give feedback.
To anyone who might be running into this same issue, I found my solution.
In functions.php, when I'm enqueuing my JS file, in addition to 'wp-element' I also needed to include 'react-jsx-runtime' as a dependency as well.
Happy coding to you all 🎉