F
F
fif2022-04-02 15:59:20
typescript
fif, 2022-04-02 15:59:20

What type to give an array of html elements?

Here is an example card:

const card = (
      <div className="card">
        {image}
        <p className="formCard-item formCard-name">
          Name: <span>{name}</span>
        </p>
        <p className="formCard-item formCard-gender">
          Gender: <span>{gender}</span>
        </p>
        <p className="formCard-item formCard-birth">
          Who was born: <span>{birthday}</span>
        </p>
        <p className="formCard-item formCard-continent">
          From: <span>{continent}</span>
        </p>
      </div>
    );

I have an array to which such cards are added, what type will this array have? Tried Object[] , JSX.Element[]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Proskurin, 2022-04-02
@Vlad_IT

Why didn't JSX.Element[] fit?
But I usually put React.ReactNode (for array React.ReactNode[]) because a node can be not only a JSX element, but also a string, null, an array, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question