Alessandro Carrese Alessandro Carrese - 3 months ago 39
React JSX Question

React componentClass on codecademy, what's wrong?

I'm learning React through Codecademy and it asks :


On line 20, declare a new variable named Friend.

Set Friend equal to a component class, made with React.createClass().

Pass an object to React.createClass().

Give this object one property. Make the property's name render.

Make the property's value this function:

function () {


`return (`
`<div>`
`</div>`
`);`


}



my code is this:

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

var friends = [
{
title: "Yummmmmmm",
src: "https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-monkeyweirdo.jpg"
},
{
title: "Hey Guys! Wait Up!",
src: "https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-earnestfrog.jpg"
},
{
title: "Yikes",
src: "https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-alpaca.jpg"
}
];


var Friend=React.createClass({
render: function(){
return (
<div>
</div>);
}

});


I can't figure out where I'm wrong

Answer

ridiculous error, React and ReactDOM should have the var keyword

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