Posted by Igor Benic

Web Developer who mainly uses WordPress for projects. Working on various project through Codeable & Toptal. Author of several ebooks at https://leanpub.com/u/igorbenic.

7 Comments

  1. Hello Igor,
    I see that you have used vanilla html controls in your react component and then integrated reactjs with WordPress. However I am still unable to wrap my head around integrating prebuilt react UI components like

    https://www.npmjs.com/package/react-player
    https://video-react.js.org/
    https://fritz-c.github.io/react-image-lightbox/

    in my react component and then integrating the component with WordPress. How would we do the same?
    I have been told to build the component (with the prebuilt react UI components), generate the bundled javascript\css files for the component using webpack (or the create-React-app build scripts) and then enqueue them in wordpress. This however does not work. please see here: https://stackoverflow.com/questions/49142418/how-to-fix-exports-is-not-defined-error-on-create-react-app-project

    Similarly in this tutorial, you have a added a “No recommended in production, better to babelify your script”, when registering\enqueuing babel-js scripts. Can you provide more details around the same, in your next tutorial?

    Reply

  2. I have an article on setting up Webpack 3 to work with ES6 and later so that might help you. https://www.ibenic.com/configuring-webpack-wordpress/

    I have not yet encountered such issue so I could not give you any advice from my own experience. But if you do happen to solve it, please let me know in a reply on this comment.

    Reply

  3. I installed this and I’m getting an error “Target container is not a DOM element”. How do I fix this?

    Reply

    1. Hi Ilene, I’ve tried it and it works fine on my side. Can you check if all the code is written correctly?

      Reply

  4. Hi Igor,
    Thanks for this great tutorial. Is it really necessary to load the two react scripts ?
    Can we just use [‘wp-element’] as a dependency when we register our script ?
    And then using wp.element instead of React in the js ?
    Thanks a lot

    Reply

    1. Hi Ravon, this tutorial was done before Gutenberg started so such dependencies were not yet available. You could try doing that, just be sure the wp.element dependency has the React DOM element that you can use to load the app onto an HTML element.

      Reply

  5. Wow so fast an answer : thx a lot !

    Reply

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.