我正在使用 'react-native-dropdown-picker';我想在 react native 中显示从 sqlite db 到下拉列表的值,我该怎么做?

I am using 'react-native-dropdown-picker'; I want to show values from sqlite db to dropdown in react native, How do i do that?

constructor() {
   super();
    this.state = {
      highcourtname: [],
    }
  }

  getFromDatabase = () => {

    var that = this;
    db.transaction((tx) => {
      tx.executeSql('SELECT Distinct(Court_Name) FROM court_images', [], (tx, results) => {
        var len = results.rows.length;
        if (len > 0) {
          for (let i = 0; i < len; i++) {
            let rowall = results.rows.item(i);
            console.log(rowall);
            //this.setState({highcourtname: rowall.name})
          }

        }
      });
    });
  }

<DropDownPicker
    items={[
        {label: 'UK', value: 'uk'},
        {label: 'France', value: 'france'},
    ]} //how to get rowall value here??

    defaultValue={this.state.highcourtname}
    onChangeItem={item => this.setState({
        highcourtname: item.value
    })}
/>

我使用了 'react-native-dropdown-picker' 的 DropDown; 我想在本机反应中将我的 sqlite 数据库中的值显示到 dropview。 我从 sqlite 数据库中获取值,有 console.log 并检查了它,但不知道如何在上面的下拉项目中显示。

如何在项目下拉列表中显示“rowall”值???

我该怎么做?如果有人可以帮助。

我是 React Native 开发新手..

只要正确设置你的状态就大功告成了

if (len > 0) {
   let rowall = []
   for (let i = 0; i < len; i++) {
        rowall.push({label: results.rows.item[i].name, value: results.rows.item[i].value});
   }
   this.setState({highcourtname: rowall})
}

<DropDownPicker
    items={this.state.highcourtname}

    defaultValue={this.state.highcourtname}
    onChangeItem={item => this.setState({
        highcourtname: item.value
    })}
/>