Tell us what’s happening:
I can’t complete the challenge because i didn’t understand the explanation,
so, i go to react website to get information about rendering but no benefit
also.
Please some one help to complete this challenge with explanation. Your code so far
const JSX = (
<div id="challenge-node">
<h1>Hello World</h1>
<p>Lets render this to the DOM</p>
</div>
);
// change code below this line
ReactDOM.render(<challenge-node/>,document.getElementById('challenge-node'))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.
Hi @oliverdudman,
Thank you very much for helping, i read your explanation, but still have a problem,
if you can give me solution it will be better, so i can understand it from solution.
My new code here
const JSX = (
<div id="challenge-node">
<h1>Hello World</h1>
<p>Lets render this to the DOM</p>
</div>
);
// change code below this line
const element = <p>Hello from my node</p>;
ReactDOM.render(element,document.getElementById('challenge-node'));
var ReactDOM = require('react-dom');
var React = require('react');
var tag = React.createClass({
render: () => {
const JSX = (
<div>
<h1>Hello World</h1>
<p>Lets render this to the DOM</p>
</div>
);
return JSX;
}
});
// change code below this line
ReactDOM.reder(tag, document.getElementById('challenge-node'));
It show error follows:
// running test
require is not defined
require is not defined
require is not defined
require is not defined
// tests completed
as you already have a const with the element written for you. It is the JSX element that you will need to pass to the render function and not the element you have created. Have another go and come back if you are still having trouble.
That’s correct, if you are doing the same challenge, then you have changed lines of code that you shouldn’t. You will need to reset the code to the original. Think about what you need to do to this line:
This is the only line of code you will need, there is a spelling mistake and if you have reset your code, then the will no longer be a tag variable. (you do not need to create one)
const anyNameHere = (
<div>
<h1>Hello world</h1>
<p>Let's render this to the DOM</p>
</div>
);
reactDOM.render(anyNameHere, document.getElementById("challenge-node");
will result in:
<div class="challenge-node">
<div>
<h1>Hello world</h1>
<p>Let's render this to the DOM</p>
</div>
</div>
If you copied and pasted the code (don’t do that though), then you would have the right output. If you examine the code then you will see that there is only one thing different. There is a reason why I called my const anyNameHere. It could for example be called JSX.
If it were, in the render method we would then replace anyNameHere with JSX.
Sorry for not giving a solution yet, it is important that you learn to recognise where you have gone wrong. If you can’t get it this time then, I will post an answer.
const JSX = (
<div>
<h1>Hello World</h1>
<p>Lets render this to the DOM</p>
</div>
);
// change code below this line
ReactDOM.render(JSX,document.getElementById("challenge-node"));
Oliver, thank you for this well craft explanation and not just putting the answer - it is too easy just to see the answer and move on but actually this is a better way of doing explain it