D
D
djEban2022-04-01 12:14:30
typescript
djEban, 2022-04-01 12:14:30

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

2 answer(s)
U
uRoot, 2022-04-01
@uroot

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 question

Ask a Question

731 491 924 answers to any question