A
A
Alex Krynytskyi2021-01-26 14:43:10
React
Alex Krynytskyi, 2021-01-26 14:43:10

How to pass something from a child component to a parent component in React?

I can not understand how to correctly implement the task.

There is a Home
page and there is a component inserted button

In Home created a variable counter = 0

I want the button to do counter++ and return the data back to Home

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
romankononovich, 2021-01-26
@NEOmanceR

In Home, describe the function to change counter. And pass through the props to the button component. In button hang this props on onClick event

0
0xD34F, 2021-01-26
@0xD34F

Hey, who did the documentation for?

V
Vlad, 2021-01-26
@vchpro

Through custom events.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question