Answer the question
In order to leave comments, you need to log in
How to output N components?
Good afternoon, I need to display 5 identical components, how to do this?
Now I do this:
const count = 5; // передается в props
const items = Array(count).fill(1).map( (item, index) => <MyComponent key={`_${index}`} /> );
const count = 5;
const items = [];
for(let i = 0; i < count; i++) {
items.push(<MyComponent key={`_${i} />);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question