React Native RadioForm从Firebase添加初始状态

时间:2017-11-15 19:15:36

标签: javascript react-native

我正在尝试创建一份记录学生技能的评估表。

我正在尝试使用RadioForm来保存这些记录并轻松编辑它们,但我似乎无法从我的firebase数据中设置无线电形式的初始值。

   

<ListView
      enableEmptySections
      dataSource={ this.fonteDeDados }
      renderRow={data => { 
                                
      return(
                        
     <View style={{ flexDirection: 'row' , width:300, borderWidth:1, borderColor:'#000' }}>
     <View style= {{backgroundColor:'#fff', padding:3, alignItems:'flex-start', justifyContent:'center', flex:1.5}}>
     <Text style={{margin:2}}>{data.criterio}</Text>
     </View>        
<RadioForm
 radio_props={[{label: 'Above', value: '0' },
 {label: 'Meeting', value: '1' },{label: 'Below', value: '2'}]}
 initial= {this.initial(this.props.caminho)}
 formHorizontal={true}
 style={{padding:10}}
 labelHorizontal={false}
 onPress={(value) => {this._clicaOption(data.criterio, value),  console.log(this.props.caminho)}}
                            />
                            
                            
                                 </View>
                         )
                         }}
                          />

我的数据读取如下:

Object {
  "Li4uY2FuIGdvIHVuZGVyd2F0ZXI=": Object {
    "N": Object {
      "Isabela": Object {
        "index": "0",
        "valor": "Above expectations",
      },
    },
    "PN": Object {
      "Clarissa": Object {
        "index": "0",
        "valor": "Above expectations",
      },
    },
    "criterio": "...can go underwater",
  },
  "Li4uY2FuIHN3aW0=": Object {
    "N": Object {
      "Isabela": Object {
        "index": "0",
        "valor": "Above expectations",
      },
    },
    "criterio": "...can swim",
  },
  "Li4uZW50ZXIgdGhlIHdhdGVyIHNhZmVseQ==": Object {
    "criterio": "...enter the water safely",
  },
}

caminho在mapStateToProps中定义为:

let caminho = 'data.' + nomeGrupo + '.' + nomeAluno + '.index'

返回这样的路径:

data.PN.Clarissa.index

更新:

我尝试使用数据[this.props.groupName] [this.props.studentName] .index,它只有在数据库中已经创建了路径时才有效,如果不是应用程序崩溃为'unefined object'< / p>

我是反应本地的乞丐,会很感激帮助。

此致

0 个答案:

没有答案