I maintain a complete React web app, which exclusively uses hundreds of class components. While the app uses the latest version of React, hooks are not currently being used anywhere. I recently encountered the need to add several new simple stateful components. Would it be proper to create these as class components (in line with all previous components), or would it be appropriate to create these as function components using hooks. I ask because this would be the first and only time I would be importing the { useState }
module (and other hooks modules), and I'm not sure if the cost of importing these tools is worth whatever benefit is attained from using hooks in only several components.
Thanks, any advice is appreciated
To my mind if you really need to use functional components with hooks, why not? Even if the whole app is using class components. It works together well. Moreover react always have had functional components(stateless), now we have hooks and that is good) but... If you want to keep your app's consistency you definitely should use exactly class components till your app's fully refactoring. Anyway it's time to refactor your class components to functional ones moreover I believe the class components will be deprecated soon.
Resume: I do not see anything bad if you start using react fc with hooks in your app.