Pass a Callback as Props: Method "Text"

Pass a Callback as Props: Method "Text"
0

#1

What am I missing here? Suggestions welcome.

Your code so far


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() {
    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>
        <h3>{this.props.input}</h3>
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/68.0.3440.75 Chrome/68.0.3440.75 Safari/537.36.

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


#2

it works for me. Try refreshing the page and/or reset the code and paste your new lines in again.


#3

Same here!

When I add the segment that is required to write, it works fine. but when I copy your whole code and paste it there, it does not work anymore.

“Resetting All” and inserting your piece of code once again may help.


#4

Thank you for the feedback @hbar1st and @Tchoukoualeu. I will try to reset the code and write it again. I also have a suggestion for developers that is when I open a previous challenge to review it, please display the code that I have written to pass the challenge. I think it is a better feature than “download my solution” feature which pops ups when I submit the challenge. Maybe I need to create a forum post about it, but if you guys are in personal touch with the FCC’s developers please convey my message.


#5

FCC devs are just volunteers who fix issues on github.
You can open a github issue if you like but I’m not really sure what it is that you are trying to say.


#6

@hbar1st, I’m sorry, I realize that statement wasn’t articulate. I feel dumb when I’m conversing with English speakers :slight_smile: .

What I mean is: when I open a previous challenge that I have already completed, it should display the code that I had passed it with. This is important when I’m trying to review and revise the lessons here.

I hope you understand what I’m trying to convey here.


#7

i think someone had a similar comment on the forum before and the response was that your browser should keep the answers you had, not the FCC server. So if the browser loses those answers (say you switch browsers), then your answers will also be lost.