Press Run, nothing happens


#1


https://www.codecademy.com/en/courses/react-102/lessons/child-updates-parents-state/exercises/child-parent-pass-handler?action=lesson_resume

Hi! I am facing a bug at exercise 3. When I press Run, the progress marker spins for a while, but then stops and nothing happens. Sometimes if I refresh the page or log out/log in again, pressing Run will result in a 'failure' box, but without any message appearing on the screen to help me. I've tried this on Opera and Chrome so I don't think it's platform-dependent. Please help.


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

var Parent = React.createClass({
  getInitialState: function () {
    return { name: 'Frarthur' };
  },
  
  handleChange : function (newName) {
    this.setState({
      name: newName
    });
  },

  render: function () {
    return (
    	<Child name={this.state.name} onChange={this.props.handleChange} />
    );
  }
});

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


#2

Mine is doing the exact same thing :frowning:


#3

First off, you should change the function name of handleChange to changeName as that's what the instructions called for. Secondly, it should be onChange={this.changeName} not this.props.foo. If you insist on keeping your function name, update your onChange={this.props.handleChange} to onChange={this.handleChange} but I can't guarantee that the tests the code academy shell runs will accept it rather than pass an error. i.e. "Press Run, nothing happens"


#4

Mine is doing the same thing. tried both this.changeName and this.props.changeName


#5

As of today, I got it to work using this.changeName . I'm not sure why this worked as the very next exercise is showing this.props.changeName ? I don't remember if I tried this.changeName yesterday.


#6

I was able to debug for Digital Slayer b/c his code was posted. If anything, use a diff checker between your code and Slayer's and find out what the other difference is.


#7

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