Search code examples
reactjscodepen

React - Extremely simple Codepen will not show up


I have a codepen. I need it to literally say "Hello world" with React. I can't get the code to render.

I have Babel set as the pre-compiler.

I have both React and ReactDOM linked.

Here is all of the HTML:

<div id="app"></div>

Here is all of the JS:

class App extends React.Component {
  render() {
    <div>
      <p>Hello!</p>
    </div>
  }
}

ReactDOM.render(<App />, document.getElementById('app')); 

I need to get this going for an interview in an hour or two. Just can't get it working here. Help!


Solution

  • You need to return the content from the render function to display.

    class App extends React.Component {
      render() {
        return (
          <div>
            <p>Hello!</p>
          </div>
        }
    }