Answer the question
In order to leave comments, you need to log in
When do you use type and when do you use intefcace in React?
Hello.
When do you prefer to use type and when do you prefer interface in React?
I know that opinions are divided, hence the following question.
Interestingly, someone in general only type and uses, which, in principle, is justified
Answer the question
In order to leave comments, you need to log in
We use interface on the gallery when we need to describe an object, for example, a props or state object. Through interface it is easier.
And type is used for some separate variable, let's say the value of this variable can be strictly defined, for example "error" | "warning" | "good". Then, as I wrote, they use type.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question