Search code examples
reactjscomponentsreact-hookslifecycle

ReactJs lifecycle confutation


I have created a website with ReactJs using the lifecycle method. But, recently I have read some blogs, where they said that we should need to avoid the ReactJs lifecycle method when we will create a production-level application. It will help us to always keep the application up-to-date. They also said that ReactJs strongly suggest using the functional components, hooks, etc. So, can you please let me know what is the real guideline for the ReactJs application? I am sorry, I do not find anything on their official website.


Solution

  • If you have already developed the application which uses component's life cycle method,it is completely fine. As mentioned in the officials - https://reactjs.org/docs/hooks-intro.html you need not to migrate / revamp lifecycle to hooks suddenly if already your application is in use/distributed, as there are no plans to eliminate classes yet.

    But if you are developing something new or in early stage of development,you should always consider using hooks, functional components as it let you split your code into chunks which some developers were finding difficult while using lifecycle methods.