1

I am just trying to print the data test foo using react. In my app.js file i have written the following code

/** @jsx React.DOM */
(function(){
  'use strict';

var Quiz = React.createClass({
  render:function(){
    return <div> test {this.props.data}</div>;
  }
}); // react class Quiz

ReactDOM.render( <Quiz data={"foo"} />, document.getElementbyID('#baseNode') );   

})(); 

but in place of document.getElementById('baseNode') if i use $('#baseNode') it throws me an error react.js:18307 Uncaught Error: Invariant Violation: _registerComponent(...): Target container is not a DOM element. I have an div with id baseNode in my html Page

1 Answer 1

2

$('#baseNode') returns jQuery Object, but second argument should be HTMLElement., $('#baseNode')[0] is equivalent to document.getElementById( 'baseNode')

ReactDOM.render(
  <Quiz data={"foo"} />, 
  $('#baseNode')[0]
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.