Pass a Callback as Props error: Element type is invalid

Pass a Callback as Props error: Element type is invalid
0

#1

I think i have added what all is necessary, haven’t i ?
but i receive react error #130 -
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.


class MyApp extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      inputValue: ''
    }
    this.handleChange = this.handleChange.bind(this);
  }
  handleChange(event) {
    this.setState({
      inputValue: event.target.value
    });
  }
  render() {
    GetInput = {}
    return (
       <div>
        { /* change code below this line */ }
        <GetInput input = {this.state.inputValue} handleChange = {this.handleChange} />
        <RenderInput input = {this.state.inputValue} />
        { /* change code above this line */ }
       </div>
    );
  }
};

class GetInput extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h3>Get Input:</h3>
        <input
          value={this.props.input}
          onChange={this.props.handleChange}/>
      </div>
    );
  }
};

class RenderInput extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h3>Input Render:</h3>
        <p>{this.props.input}</p>
      </div>
    );
  }
};

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/pass-a-callback-as-props


#2

Why did you assign an empty object to GetInput here? You have redefined what GetInput is.