I want to add a "Widget" that is built with React.js to my WordPress site. It will not be dependent on any outside data. Besides adding npm modules and adding build processes to my Gruntfile (to convert JSX to JS), what other steps do I need to take to show a very simple React Component like below?

var React = require('react');   
var App = React.createClass({
    getInitialState: function(){
        return {
            name: "Jake"
    render: function(){
        return (
            <h1> {this.state.name} </h1>
} );    
React.render(<App />, document.getElementById( 'app' ) );

Where would this JavaScript file live in the typical WordPress file structure?

  • Are you building a plugin or a theme? – mAAdhaTTah Feb 25 '17 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.