Answer the question
In order to leave comments, you need to log in
How to display every 3 elements in your div?
There is an array, you need to display 3 elements in each div so that the code is like this:
<div class="row">
<div>element</div>
<div>element</div>
<div>element</div>
</div>
<div class="row">
<div>element</div>
<div>element</div>
<div>element</div>
</div>
Answer the question
In order to leave comments, you need to log in
easier than that, I don't know. https://jsfiddle.net/vaheqelyan/fsc6qweh/
class App extends React.Component {
state = { arr: ["hello", "world", "wow", "react"] };
render() {
return (
<section>
{this.state.arr.map(v => (
<div className="row">
<div>element</div>
<div>element</div>
<div>element</div>
</div>
))}
</section>
);
}
}
ReactDOM.render(<App />, document.body);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question