MichaelP
MichaelP

Reputation: 41

How To Use ReactJS in Wordpress Plugin

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.

Upvotes: 2

Views: 1111

Answers (1)

MichaelP
MichaelP

Reputation: 41

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

Upvotes: 1

Related Questions