0

So I was trying to setstate a variable with jsx and spread operator but no matter how I try I get stuck without any output or with errors can anyone please help me how to achieve this??
Here is the part of program

handleNumberOfGyInput=(e)=>{
      e.preventDefault();
      this.setState({numberofGyBranchesInput:null})
      for(let i = 1;i<this.state.numberofGyBranches;i++){
        this.setState(prevState=>({gyAddressInput:
         ...prevState.gyAddressInput +
          <React.Fragment >
          <Row>
            <Form.Group className="mb-3" controlId="formGridAddress1">
                <Form.Control placeholder="Address of something(s) {click on + button below to add more addresses for diffrent branches}" />
            </Form.Group>
          </Row>
        </React.Fragment>
        }))
      }
    }

so here is what I am trying to achieve :
I want my JSX Component (between "Row") to be rendered as many times as number that this.state.numberofGyBranches variable carries can anyone tell me how??

streak
  • 79
  • 1
  • 9
  • answered here: https://stackoverflow.com/questions/25646502/how-can-i-render-repeating-react-elements/51359938#51359938 – streak Oct 16 '21 at 16:20

1 Answers1

0

Uhm, I think you are doing React the wrong way buddy!

justin
  • 325
  • 1
  • 5