Help with Render a Class Component to the DOM?

Tell us what’s happening:
I tried everything I possibly could but my code still doesn’t work. Could it be something to do with FreeCodeCamp itself or do I have to add/remove something else in my code?

Your code so far


class TypesOfFood extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h1>Types of Food:</h1>
        {/* change code below this line */}
        <Fruits/>
        <Vegetables/>
        {/* change code above this line */}
      </div>
    );
  }
};

// change code below this line
ReactDOM.render(<TypesOfFood />,'challenge-node')

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36.

ReactDOM.render(<TypesOfFood />,'challenge-node')

The second argument of this is incorrect – you need to render to a DOM node, which you can get with document.getElementById The challenge text to the left should contain an example of how to use that particular method. Hope this helps. :slight_smile:

1 Like