Where does newName come from?


#1


https://www.codecademy.com/courses/react-102/lessons/child-updates-sibling/exercises/stateless-inherit-stateful-recap?action=lesson_resume


I'm at the end of this lesson and my code works, but I don't understand it. I understand that Parent inherits Child and Siblings' props to update it's state, but usually this is passed through a variable called "name". "name" is collected through the element's onChange attribute, where the event is captured from the 's value attribute. From there, it's passed into changeName, and there's the newName argument, but it's never referenced anywhere else. Does React understand "new" as a prefix or am I not understanding something? I know arguments can be named anything, but usually they're named to relate to a global variable like "name" is.

Why does newName work?


var Parent = React.createClass({
// getInitialState function
 changeName: function (newName) {
    this.setState({
      name: newName
    });
//render function


#2

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