0

My entire code looks like this:

<!DOCTYPE html>
<html>
<head>
    <title>React course</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://unpkg.com/react@15/dist/react.js"></script>
    <script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.25.0/babel.min.js"></script>
</head>
<body>

    <div id="example"></div>

    <script type="text/babel">

        var Comment = React.createClass({

            edit: function () {
                alert('Editing comment');
            },

            remove: function () {
                alert('Removing comment');
            },

            render: function() {
                return (
                    <div className="commentContainer">  
                        <div className="commentText">Text of whatever</div>
                        <button onClick={this.edit} class="btn-primary">Edit</button>
                        <button onClick={this.remove} class="btn-danger">Remove</button>
                    </div>
                );
            }
        });

        ReactDOM.render(
            <div className="board"> 
                <Comment>Heya</Comment>
            </div>
        ,document.getElementById('container')); 
    </script>
</body>

When I refresh the page I see nothing. Then I inspect the element and I see the error that you see in the image but I do not really know what is going know since am new in react.

Hope you can help

enter image description here

2
  • 1
    You don't have element on a page called container, only <div id="example"></div> Commented Jul 31, 2017 at 9:52
  • Thanks it was that. For some reason I didn't notice Commented Jul 31, 2017 at 9:54

1 Answer 1

3

I think it because you don't have an html element with an id of container. This section must reference a valid HTML element. document.getElementById('container'));

Try changing the id of example to container.

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

1 Comment

Thanks it was that. For some reason I didn't notice

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.