Manage Updates with Lifecycle Methods

Manage Updates with Lifecycle Methods
0.0 0

#1

Tell us what’s happening:

the code passes all tests but in console i get the error e.onNext is not a funtion when i press update button.

If i remove all the lifecycle the button works.
If i keep the one provided(componentWillUpdate) or any other combination with the other two i get the same error.

Your code so far


class Dialog extends React.Component {
  constructor(props) {
    super(props);
  }
  componentWillUpdate() {
    console.log('Component is about to update...');
  }
  // change code below this line
  componentWillReceiveProps(nextProps) {
    console.log(this.props + '-' + nextProps)

  }

  componentDidUpdate() {
    console.log('Component did update')
  }
  // change code above this line
  render() {
    return <h1>{this.props.message}</h1>
  }
};

class Controller extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      message: 'First Message'
    };
    this.changeMessage = this.changeMessage.bind(this);
  }
  changeMessage() {
    this.setState({
      message: 'Second Message'
    });
  }
  render() {
    return (
      <div>
        <button onClick={this.changeMessage}>Update</button>
        <Dialog message={this.state.message} />
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/manage-updates-with-lifecycle-methods/


#2

As near as I can tell, that is an issue with the testing software or interface. I notice that this happens even if I reset the code. But you passed and it looks like you did it right. If you want to be a mensch, you can go to the github page and raise the issue if no one else has.


#3

Ok i’ll look if the issue exists on github.

Thanks