S
S
Shakir Darion2019-10-08 02:34:19
JavaScript
Shakir Darion, 2019-10-08 02:34:19

When is it better to use a class component and when is it better to use a functional component?

When I go to an interview, they ask me when is the best time to use a class bean and when is it best to use a functional bean?. I do not know the answer to this question. I know the difference between them. What is the best way to answer this question?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abberati, 2019-10-08
@shakiriker

TL;DR class components must be used to create error boundaries and with ssr. Otherwise, the function component will be shorter and simpler.
If you want to understand what functional components can and cannot do, here is a detailed explanation .
It says that this is not for beginners - so you really need to understand what components are, how they are created as a class, and how - as a function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question