jeudi 23 novembre 2017

React Native Dynamic Checkbox Inside Dynamic checkbox

I have a app developed in React native and I need make a dinamic checkbox list inside other dynamic checkbox list, the first list works fine, but when i try to make the other dynamic checkbox list inside, this not show totally.

this is the code:

<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 =
                      textStyle = 
                      checkedIcon = 'dot-circle-o'
                      uncheckedIcon = 'circle-o'
                      onPress = {(checked) => this.cambioCheckCat(categoria.id)}
                    />
                    {
                      this.state.checkCategorias[categoria.id-1] ? 
                      <View
                       style =
                       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 =
                                textStyle = 
                                checkedIcon = 'dot-circle-o'
                                uncheckedIcon = 'circle-o'
                                onPress = {(checked) => this.cambioCheckSub(subcategoria.id)}
                              />
                              )
                            }
                          })
                        }
                      </View> : null
                    }
                  </View>
                )
              })
            }
          </View>

This show fine until the line "Selecciona una o varias categorias...", after i have a .map but this part simply not show.




Aucun commentaire:

Enregistrer un commentaire