Uncaught ReferenceError: mountNode is not defined

前端 未结 2 1077
感动是毒
感动是毒 2021-02-18 18:02

forgive me i\'ve searched everywhere and I\'m new in reactjs and trying out examples. I have an error

Uncaught ReferenceError: mountNode is not defined 
<         


        
相关标签:
2条回答
  • 2021-02-18 18:21

    Being the accepted answer done, I'd like to add one thing: Don't forget to include references to all necessaries js's libs in your html head section if you are testing this out of "kit examples folder"

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://npmcdn.com/react@15.3.1/dist/react.js"></script>
    <script src="https://npmcdn.com/react-dom@15.3.1/dist/react-dom.js"></script>
    <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
    
    0 讨论(0)
  • 2021-02-18 18:24

    You need to tell React where to mount the <UserGist /> component. You probably want to replace mountNode with document.getElementById('example') to refer to your <div id="example"></div> element:

    React.render(
      <UserGist source="https://api.github.com/users/octocat/gists" />,
      document.getElementById('example')
    );
    
    0 讨论(0)
提交回复
热议问题