C
C
connecter2019-07-31 18:55:38
React
connecter, 2019-07-31 18:55:38

How to listen for a change in props?

Hello, how to understand that props has changed?
That is, I have some data in the component (com1), which I send from another component (com2) and I need to do some actions in com1, when the data in props changes

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-07-31
@connecter

componentDidUpdate(prevProps) {
  if (prevProps.someProp !== this.props.someProp) {
    // do something
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question