DEV Community

Discussion on: How to use React inside a Wordpress application ?

Collapse
 
saiayyappa profile image
saiayyappaor

Hey Julien, thanks this plugin is a life saver. I didn't want to code PHP and kinda stumbled upon this blog. This is a cool thing. When I try to follow the exact steps I get this

Uncaught TypeError: n.render is not a function
    <anonymous> index.js:7
    <anonymous> index.js:11
    <anonymous> index.js:11
Enter fullscreen mode Exit fullscreen mode

in my browser console. I can see the paths for css and js in the created app is set proper. I think when the js is loaded this render call fails, don't know why...

Collapse
 
saiayyappa profile image
saiayyappaor • Edited

Julien was able to find alternate way. I used wp.element for loading react and react-dom instead of directly packaging it from create-react-app. We have to use wp-scripts instead from where wp.element comes from. Once using that we also have to load/enqueue wp.element where we init our plugin (php file where we register it as shortcode).
Seriously thanks for the input on where to get started.