How to make a clone of the component when you press the button?

How do you clone a component by clicking on the button in
June 5th 19 at 21:34
2 answers
June 5th 19 at 21:36
Components should be drawn in a loop ( map forEach'ω or ohms ). The data must lie in state. When you click on "add" - there is a new record in the state, and the component is automatically filled.

Pseudo code:
state = {
 modelSelectors: [{obj1}, {obj2}]

renderSelectors = () => { => <select ...>

addSelector = () => {
 this.setState({ modelSelectors: +1 element in the array })
June 5th 19 at 21:38
Reakt's not about working with the DOM, react about the rendering of the interface based on the state. You should consider what structure best fits the state task (array of objects) and on its basis to draw the shape. In 99 cases out of 100 do not need any components anywhere clone

Find more questions by tags React