GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Modul 26 von 28 · Medien

Changing parent's state through Form

Kostas Diakogiannis

Changing parent's state through Form

Changing parent's state through Form

Now we will give the <FormInput /> component the power to change the state by passing the updateValue function to this component as a prop!

At the same time we will use the current state of the input value every time to update the depicted message! We will use again the props here in order to achieve this effect.

It is extremely important here to bind the function as it is shown to the second image down. That means that the function will be executed inside the FormInput component but the state is going to be <App /> component state! So in other words, we change App’s state from the FormInput component.

Then we use the passed prop function every time the field is updated and the data is changed!

Anleitung

Um im Kurs weiterzukommen, sende einen Versuch dieses Quiz ab. Du kannst ihn nach der letzten Frage absenden.

Zum gewählten Modul

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck