N
N
Norwood2021-02-21 16:26:18
React
Norwood, 2021-02-21 16:26:18

How to insert App() again on the page?

Good afternoon. There is a block that needs to be inserted into the page 5 times. I made it, but I don't know how to insert it. There is an option in the index.js file to write 5 times. But this is probably not the right choice. Can you suggest how this can be done?

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

import './App.scss';
import {Button} from "./Button";

function App() {
  return (
    <div className="App">
      <div className="containerComponent">
        <div className="number">11</div>
        <Button/>
      </div>
    </div>
  );
}

export default App;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valery, 2021-02-21
@Norwood

ReactDOM.render(
  <React.StrictMode>
    {Array.from({length: 5}, () => <App />)}
  </React.StrictMode>,
  document.getElementById('root')
);

^_^

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question