Does that mean you now choose functional components first? What is your thought process as you begin? With hooks I do know many if not all require functional components which was very restrictive in the past. I’m thinking of making the transition next time I have to create a new component. Thanks!
Yes, now I'll typically opt to use functional components first. Having gained more experience since I wrote this blog, I'm finding that functional components are not as limiting as I also used to believe, and that I can, in fact, perform a lot of common lifecycle methods using hooks, so there's no real incentive for me to go back to using class components. I will say that I don't feel completely comfortable using a particular hook and I'm in a real pinch, I might consider using a class component. But like I mention in this blog, I like to stay consistent, so I'll continue working on my hooks skills so that I can just use functional components every time.
And one more note about why I use functional components:
I'm discovering that there are a lot of React-based packages that I may want to use, such as React-Bootstrap, and if I want to be able to apply those packages to my app component, it's better that I get used to writing functional components.
Good luck with your transition! Hope it's a happy one!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Does that mean you now choose functional components first? What is your thought process as you begin? With hooks I do know many if not all require functional components which was very restrictive in the past. I’m thinking of making the transition next time I have to create a new component. Thanks!
Yes, now I'll typically opt to use functional components first. Having gained more experience since I wrote this blog, I'm finding that functional components are not as limiting as I also used to believe, and that I can, in fact, perform a lot of common lifecycle methods using hooks, so there's no real incentive for me to go back to using class components. I will say that I don't feel completely comfortable using a particular hook and I'm in a real pinch, I might consider using a class component. But like I mention in this blog, I like to stay consistent, so I'll continue working on my hooks skills so that I can just use functional components every time.
And one more note about why I use functional components:
I'm discovering that there are a lot of React-based packages that I may want to use, such as React-Bootstrap, and if I want to be able to apply those packages to my app component, it's better that I get used to writing functional components.
Good luck with your transition! Hope it's a happy one!