almost 8 years ago
Use Jquery to get DOM elements
React.js injects code into HTML block like this:
React.render(
<EditorForm />,
document.getElementById('content)
);
To use Jquery to accomplish the samething:
React.render(
<EditorForm />,
$("#content")[0]
);
$("#content") along is not enough, because it returns a jquery object instead of a DOM object.
Why does React.js render function's return statement is surrounded by a parenthese?
This is because JavaScript does automatic semicolon insertion
When the following line is entered:
var test = 'str1'
'str2'
'str3';
The output is not an error, but instead str1 is assigned to variable test. This is because a semicolon has been inserted by js automatically like this:
var test = 'str1';
When working with React.js, this is what a typical render() looks like:
return (
<div className="form-group hovering-textarea-container">
<input className="form-control input-lg" type="text" />
</div>
);
To make sure the entire div block is returned as a whole instead of just the first line, the parenthese are needed.