3. Put Logic in a Render Function


#1


https://www.codecademy.com/en/courses/react-101/lessons/react-components-advanced-jsx/exercises/render-function-calculations

Hi ! I'm stuck at this exercise : 3. Put Logic in a Render Function with instruction 2

There is no error message and I'm pretty sure I'm right.
This is my code :

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


Help ! Thanks !


#2

The word function is written wrong

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

#3

You're right. But this doesn't work even with function well written :confused:


#4

I had the same trouble. Make sure your friend variable starts on line 20. This fixed it for me.


#5

I'm on line 20 and still nothing !


#7

I've just reset the exercise and pasted my working code, and It said I was wrong on the second point.
I then commented out the code and went through it step by step, without changing anything. And it's now working.
So i think it's just a bit temperamental about what it accepts. Here is my code:

var Friend = React.createClass({
  render: function(){
   var friend = friends[0];
    return (<div><h1>{friend.title}</h1>
      <img src={friend.src} /></div>)
  }
})

ReactDOM.render(<Friend/>,document.getElementById('app'))

hope this helps.


#8

Nope, I still have my issue


#9
<h1>{friend.title}</h1>

do the job


#10

I don't understand your answer :confused:


#12

3 posts were split to a new topic: Problem with function in render


#16

So. I reset the exercice and use this code : (I started on line 21 and note 20 as it's said)


#18

I am also having a hard time with this one, and none of the solutions worked for me.


#19

React is dependent upon the space before />, I believe.


#21

I have the same problem, dont reload the browser, but try to reset the exercises, and start from the first quesiton again. Hope this helps


#23

Hi,

I meant Restart the exercise. (not reset). You can do this by clicking of Get Help (Bottom Right coner of your browser) and then choose I want to restart the exercise
thanks,


#24

Thank you so much! I was stuck on this for nearly two days. Seems codecademy is being fickle - I had the same code, but I had to format it in the exact way you did.


#28

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