React Native Dynamic Checkbox Inside Dynamic复选框

时间:2017-11-23 22:21:39

标签: checkbox react-native

我有一个用React本地开发的应用程序,我需要在其他动态复选框列表中创建一个dinamic复选框列表,第一个列表工作正常,但是当我尝试在其中创建其他动态复选框列表时,这不会完全显示。< / p>

这是代码:

<View style ={styles.inside2}>
            {
              this.state.categorias.map((categoria) => {
                return(
                  <View key={categoria.id}>
                    <CheckBox
                      title={categoria.nombre}
                      iconRight
                      checkedColor='red'
                      uncheckedColor='red'
                      checked={this.state.checkCategorias[categoria.id-1]}
                      containerStyle ={{backgroundColor: '#f7f7f7', borderColor: '#f7f7f7' }}
                      textStyle = {{fontSize: 12, color: '#787878' }}
                      checkedIcon = 'dot-circle-o'
                      uncheckedIcon = 'circle-o'
                      onPress = {(checked) => this.cambioCheckCat(categoria.id)}
                    />
                    {
                      this.state.checkCategorias[categoria.id-1] ? 
                      <View
                       style ={{backgroundColor: 'lightgray', width: '100%', height: '100%'}}
                       key ={categoria.id+'t'} >
                        <Text style = {styles.titulo2}> 
                         Seleccione una o varias sub-categorias de {categoria.nombre}
                        </Text>
                        <View style={styles.separador} />
                        {
                          this.state.subcategorias.map((subcategoria) => {
                            if(subcategoria.id_categoria == categoria.id){
                              return(
                                <CheckBox
                                key={subcategoria.id+'s'}
                                title={subcategoria.nombre}
                                iconRight
                                checkedColor='red'
                                uncheckedColor='red'
                                checked={this.state.checkSubCategorias[i]}
                                containerStyle ={{backgroundColor: '#f7f7f7', borderColor: '#f7f7f7' }}
                                textStyle = {{fontSize: 12, color: '#787878' }}
                                checkedIcon = 'dot-circle-o'
                                uncheckedIcon = 'circle-o'
                                onPress = {(checked) => this.cambioCheckSub(subcategoria.id)}
                              />
                              )
                            }
                          })
                        }
                      </View> : null
                    }
                  </View>
                )
              })
            }
          </View>

这个显示正常直到&#34; Selecciona una o varias category ...&#34;,在我有.map但这部分根本没有显示。

编辑:

抱歉,我看到了我的错误,我从数据库中得到了数据不好,但代码工作正常,所以我把这个放在这里以防万一有人需要动态进入其他动态。

1 个答案:

答案 0 :(得分:0)

抱歉,我看到了我的错误,我从数据库中得到了数据不好,代码工作正常,我把这个放在这里以防万一有人需要动态进入其他动态。

相关问题