2

I am having trouble using ReactJs in a Wordpress plugin.

I am developing a Wordpress plugin using ReactJs. Googling only found ReactJs in a Wordpress theme, not plugin development.

1
  • I was able to use shortcode with the PHP-based of my plugin. Not sure how shortcode would work with React-based plugin. Commented Nov 15, 2015 at 15:17

1 Answer 1

1

I got it working on a plugin admin page.

Started with a working PHP-based plugin setting page. Then replaced all PHP code in the setting UI page with

<div id="content"></div>

Pre-transformed the JSX. I wasn't able to get JSX transform to work on the fly. I am not if this possible in Wordpress.

Also ran into document not ready issue. This was solved by this question.

Invariant Violation: _registerComponent(...): Target container is not a DOM element

Sign up to request clarification or add additional context in comments.

1 Comment

I get the same error when I don't use Babel. If I include Babel, this error disappears and everything is back to normal. So, this can work if you include 3 scripts, React, ReactDOM and Babel and use "text/babel" for your app.js. Without Babel it doesn't work and I'm still trying to figure it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.