F
F
freestm2017-10-15 21:21:37
JavaScript
freestm, 2017-10-15 21:21:37

How to pass data from child component to parent in react?

You can pass props to a child component, but how to pass it to a parent?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lnked, 2017-10-15
@freestm

parentСomponent {
  dataUpdate (data) {
     // тут ты получаешь данные 
  },
  render (
     <childrenComponent dataUpdate={this.dataUpdate.bind(this)} />
   )
}

childrenComponent {
   props {
     dataUpdate: func
   }
   //при любых изменениях данных передаешь их в родительскую функцию и родитель получает данные
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question