K
K
kllpff2021-06-18 17:47:27
React
kllpff, 2021-06-18 17:47:27

How to pass data from child component to parent?

There is a Parent component :

function Parent() {
  const [state, setState] = useState([])

  return (
   <Buttons />
  )
}


And child Buttons :
function Buttons() {
  return (
   <Button>1</Button>
   <Button>2</Button>
  )
}


How to change the state of the parent ( Parent ) by clicking on the buttons of the Buttons component ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question