{ 'this is treated as JavaScript code' }
. Keep this in mind, since it's used in several future challenges.
However, because JSX is not valid JavaScript, JSX code must be compiled into JavaScript. The transpiler Babel is a popular tool for this process. For your convenience, it's already added behind the scenes for these challenges. If you happen to write syntactically invalid JSX, you will see the first test in these challenges fail.
It's worth noting that under the hood the challenges are calling ReactDOM.render(JSX, document.getElementById('root'))
. This function call is what places your JSX into React's own lightweight representation of the DOM. React then uses snapshots of its own DOM to optimize updating only specific parts of the actual DOM.
div
element to the constant JSX
. Replace the div
with an h1
element and add the text Hello JSX!
inside it.
JSX
should return an h1
element.
testString: assert(JSX.type === 'h1', 'The constant JSX
should return an h1
element.');
- text: The h1
tag should include the text Hello JSX!
testString: assert(Enzyme.shallow(JSX).contains('Hello JSX!'), 'The h1
tag should include the text Hello JSX!
');
```