Adding React to a Website

Let’s do something really simple here and add the like button example with React.js to our page! If you are seeing an interactive like button here, then React is fully functional!

This is the code that produced the like button:

<!-- We will put our React component inside this div. -->
    <div id="like_button_container"></div>

<script src="" crossorigin></script>
<script src="" crossorigin></script>

<!-- Load our React component. -->
      'use strict';

      const e = React.createElement;

      class LikeButton extends React.Component {
        constructor(props) {
          this.state = { liked: false };

        render() {
          if (this.state.liked) {
            return 'You liked this.';

          return e(
            { onClick: () => this.setState({ liked: true }) },

      const domContainer = document.querySelector('#like_button_container');
      const root = ReactDOM.createRoot(domContainer);