A
A
Artur Kudashev2019-03-19 14:13:20
React
Artur Kudashev, 2019-03-19 14:13:20

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

2 answer(s)
A
Anton Spirin, 2019-03-19
@archi_kud

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.

D
davidnum95, 2019-03-19
@davidnum95

projects.wojtekmaj.pl/react-lifecycle-methods-diagram

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question