Home > Software engineering >  How to render a react component and replicate them from the click event
How to render a react component and replicate them from the click event

Time:07-16

I want to make multiple copies of Form2 React Component with click event, but the code not working as I want, I am new in react so can anybody help me.

const Comform = () => {


const Form2 = () => {
       
       
      return(

      <div className="card" id='form-card2'>
         <input className="form-check-input" type="checkbox" value="" id="options-check" onClick={Optionscheck} />
      </div>
      
         
     );
    
    }

const Replica = () {
          
          <Form2/>          
            
}

   return(


        <button type="button" className="btn btn-success" onClick={Replica}>Add</button>
   );

   
}
    

CodePudding user response:

Keep a state as the replica counter and render the number of items you want using Edit replicating-form-items

  • Related