Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
146
rated 0 times [  152] [ 6]  / answers: 1 / hits: 21359  / 10 Years ago, mon, may 12, 2014, 12:00:00

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 http://facebook.github.io/react/tips/initial-ajax.html



and my code looks like this



<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<script src=//code.jquery.com/jquery-1.11.0.min.js></script>
<script src=/javascripts/reactjs/react.js></script>
<script src=/javascripts/reactjs/JSXTransformer.js></script>
</head>
<body>
<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];
this.setState({
username: lastGist.owner.login,
lastGistUrl: lastGist.html_url
});
}.bind(this));
},

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

React.renderComponent( <UserGist source=https://api.github.com/users/octocat/gists />, mountNode );


</script>

</body>
</html>


Thank you in advance!


More From » jquery

 Answers
9

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')
);

[#71069] Saturday, May 10, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
clarkulisesa

Total Points: 422
Total Questions: 93
Total Answers: 112

Location: Austria
Member since Thu, Jan 7, 2021
3 Years ago
clarkulisesa questions
Mon, Feb 24, 20, 00:00, 4 Years ago
Mon, Aug 12, 19, 00:00, 5 Years ago
;