Answer the question
In order to leave comments, you need to log in
What lifecycle methods to use?
Hello, reached the topic of life cycles. The topic is easy to understand, but the documentation says that some cycles will soon be removed from React. Here I have a question. What are the most common life cycles? What life cycles do you use? And what cycles are better not to use? PS I have the latest version of React.
Answer the question
In order to leave comments, you need to log in
The documentation says it all in black and white.
Use:
componentDidMount(),
shouldComponentUpdate(),
static getDerivedStateFromProps(),
componentDidUpdate(),
componentWillUnmount()
Don't use:
componentWillMount(),
componentWillReceiveProps(),
componentWillUpdate()
Using a constructor also often doesn't make much sense as most cases it is more convenient to use class properties.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question