Stuck on JSX Variables Exercise


#1


Hi there, I've had a search around and couldn't find anyone else that's had the same problem.

I keep getting the same error, I've followed the instructions properly and have gone back to check I'm using ReactDOM.render correctly. No idea what I'm doing wrong!

Any help would be awesome,

Thanks


[https://www.codecademy.com/courses/react-101/lessons/react-jsx-advanced/exercises/jsx-variables?action=lesson_resume](https://www.codecademy.com/courses/react-101/lessons/react-jsx-advanced/exercises/jsx-variables?action=lesson_resume)

ReactDOM.render's first argument should be < h1 >{theBestString} < /h1 >. (I've added spaces in the h1 tags when posting here to prevent formatting)


var React = require('react');
var ReactDOM = require('react-dom');

var theBestString = 'tralalalala i am da best';

var greeting = <h1>{theBestString}</h1>;

ReactDOM.render(
  greeting,
  document.getElementById('app')
);


#2

This is easy! The workspace is pretty clear on this, announcing:

ReactDOM.render's first argument should be <h1>{theBestString}</h1>.

But your first argument for ReactDOM.render() is greeting because you unnecessarily put it in an additional var.

This is okay in reality, but the workspace seems to check the first argument passed to ReactDOM.render().


#3

Ah right, didn't realise you could put html tags directly in as an argument, thought they had to be put into a var first judging from the example on the page that does just that.

Thanks for the help!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.