view raw
Hokutosei Hokutosei - 8 months ago 174
Javascript Question

Uncaught ReferenceError: mountNode is not defined

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

I am following the example from here

and my code looks like this

<!DOCTYPE html>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<script src="//"></script>
<script src="/javascripts/reactjs/react.js"></script>
<script src="/javascripts/reactjs/JSXTransformer.js"></script>
<h1><%= title %></h1>
<p>Welcome to <%= title %></p>
<div id="example"></div>
<script src="/javascripts/reactjs/build/helloworld.js"></script>
<script type="text/jsx">
/** @jsx React.DOM */

var UserGist = React.createClass({
getInitialState: function() {
return {
username: '',
lastGistUrl: ''

componentDidMount: function() {
$.get(this.props.source, function(result) {
var lastGist = result[0];
username: lastGist.owner.login,
lastGistUrl: lastGist.html_url

render: function() {
return (
{this.state.username}last gist is
<a href={this.state.lastGistUrl}>here</a>.

React.renderComponent( <UserGist source="" />, mountNode );



Thank you in advance!


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:

  <UserGist source="" />,