Write a React Component from Scratch getElementById is not defined

I have the first two items but not the last.
error: MyComponent should render to the DOM.
I’ve spent 45 minutes researching and can’t find the issue.
I get “Uncaught ReferenceError: getElementById is not defined”, but I’ve even copied and pasted that from the example and it doesn’t work.

Thanks!

Your code so far


// change code below this line
class MyComponent extends React.Component {
  
  constructor(props){
    super(props);
  }
  
  render() {
    return(
        <div>
          <h1>My First React Component!</h1>
          </div>
    );
  }
};
//  I also tried adding this div at this point in the code: 
<div id="challenge-node"></div>, but no difference//

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

Your browser information:

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

Challenge: Write a React Component from Scratch

Link to the challenge:

This is the first Google result for getElementById:

It’s

document.getElementById(/* whatever the Id is */)

It’s provided by the browser, it’s a method on the document object, you can’t miss out the document. bit

1 Like

Where did you copy it from?