I don’t understand the instruction to “”“Also create a prop called handleChange and pass the input handler handleChange to it.”""
am i making a variable called handleChange in the MyApp? Naming everything the same is confusing.
Last Two Errors
How to check --> “”“The RenderInput component should receive the MyApp state property inputValue as props.”""
How to check --> “”“The GetInput component should receive the MyApp state property inputValue as props and contain an input element which modifies MyApp state.”""
Am i setting something? Am i doing something? I have no idea what goes where. This isn’t teaching me what to do and why
A function has been created for you, handleChange, which you pass to the child in a property with the same name handleChange
The idea behind this is that you can pass functions as well from parent to child, and have the child components interact via passing things in the parent
So in GetInput when the element changes, it calls handleChange() which changes the state of the parent component, which in turn changes what RenderInput displays
All of this is done simply by passing the function as a property which can be called upon change in a child.
Ok let’s back up. How am I sending a class method as a prop? You’re saying this.handleChange. Wouldn’t the value of the input tag be the value to the method?
can we break this down? I’m clearly missing something
Honestly this is the hardest thing about React, and once this ‘clicks’ it’ll seem so obvious in hindsight
We have two components here doing different things, but they’re connected like parent and child. We can pass things from parent to child via properties.
We pass them in in a way that looks exactly like html attributes, just as you’ve done already with input
The receiver, the child component, can then use what it has been given by its parent, via it’s props object
Note though, it cannot use what it has not been given, which is precisely what @camperextraordinaire is getting at - you need to pass in the function via a property in order for the child to be able to use it
I’m not following it at all I’m sorry. Not a clue what to do with RenderInput either. I don’t know what the requirements are or mean.
Test message: “”“The RenderInput component should receive the MyApp state property inputValue as props.”“”
Isn’t <RenderInput input={this.props.inputValue} /> doing that?? I guess not.
RenderInput is really just an output, and there is no input form element there. So this looks to be wrong as I don’t know how to send things to a child as props
What is handleChange={this.handleChange} even doing? Just gives me a headache.
After whatever that is, what is happening to this.handleChange inside GetInput?
what’s the difference between the value={this.props.inputValue} inside the GetInput component and this.handleChange?
why would I change the GetInput input value to this.props.input when input is not a prop? Typo on this.props.inputValue?
If the child component GetInput already has an input value and I’m passing this.handleChange down from the parent to it, what is passing and running what?
is there a clearer example somewhere that would explain this and doesn’t take hours and hours?
Thanks for all the help but I am just as lost now as before (minus the putting the method to pass down to the child, that was great).
Every little misunderstanding just compounds on itself. I don’t know the flow or the order or the expectation at any given point