【问题标题】:how to map my state using react bootstrap correctly?如何正确使用反应引导映射我的状态?
【发布时间】:2020-02-12 18:27:47
【问题描述】:

我在将状态映射到模态体内时遇到问题。当我尝试渲染它时,模态显示但它是空白的。我是不是在做一些我没有看到的错误?

我的代码:

                 <Modal show={this.state.handModal}>
                            <Modal.Header>
                            <Modal.Title>Your hand</Modal.Title>
                            </Modal.Header>
                            <Modal.Body>
                                {
                                   ()=>{ if(this.state.randomHand){
                                        return(
                                              <div> 
                                                      <h5>Your Hand</h5>

                                                  {this.state.randomHand.map((card,index)=>{
                                                      return(
                                                      <div key={index}>
                                                      <p>card</p>
                                                      </div>
                                                      );
                                                  })}
                                              </div>  
                                        )
                                    }
                                    return(
                                        <div>
                                            <h5>We are picking your hand :)</h5>
                                            <Spinner animation="border" size="sm"/>
                                        </div>
                                        )
                                    }
                                }
                            </Modal.Body>
                            <Modal.Footer>
                            <Button variant="secondary" onClick={()=>{this.setState({handModal:false})}}>
                                Close
                            </Button>
                            </Modal.Footer>
                        </Modal>

【问题讨论】:

    标签: mapping react-bootstrap


    【解决方案1】:

    尝试做,

    <Modal.Body>
       {this.state.randomHand ? <p>random hand</p> :  <p>We are picking your hand</p>}
    </Modal.bBody>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-10
      • 1970-01-01
      相关资源
      最近更新 更多