Question 3. Pass the event handler

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/react-102/lessons/child-updates-parents-state/exercises/child-parent-pass-handler?action=resume

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Not sure why I cannot get the following code working in the Parent.js

  1. Pass changeName down to Child!

In Parent.js, inside of Parent’s render function, add a second attribute to . Give this attribute a name of onChange, and a value of the changeName function.

```

var React = require(‘react’);
var ReactDOM = require(‘react-dom’);
var Child = require(’./Child’);

var Parent = React.createClass({
getInitialState: function () {
return { name: ‘Frarthur’ };
},

changeName: function (newName) {
this.setState({
name: newName
});
},

render: function () {
return (

);
}
});

ReactDOM.render(
,
document.getElementById(‘app’)
);

<do not remove the three backticks above>

No comma needed between attributes (I don’t think).
Also: onChange={this.changeName} since you’re just passing the function there.

Thanks Melissa It works now

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