React-native-multiple-select:无法读取未定义的属性“getSelectedItemsExt" [英] React-native-multiple-select: Cannot read the property 'getSelectedItemsExt' of undefined

查看:63
本文介绍了React-native-multiple-select:无法读取未定义的属性“getSelectedItemsExt"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序并引用此链接我为我的应用程序实现了相同的代码,但出现错误无法读取未定义的属性‘getSelectedItemsExt’".另一个错误是提交"按钮也没有显示.我尝试了所有方法但都失败了.

I am building an App and referring this link i implemented same code for my App, but i am getting error "Cannot read the property 'getSelectedItemsExt' of undefined". One more error is "submit" button is also not showing up. I have tried all the ways but failed.

import React, { Component } from 'react';
import { AppRegistry, StyleSheet, TextInput, View, ListView, Alert, Button,     Platform, ToastAndroid, TouchableOpacity, ActivityIndicator, Text, Picker, ScrollView }
from 'react-native';
import { StackNavigator } from 'react-navigation';
import MultiSelect from 'react-native-multiple-select';


class manage_publishers extends Component {
static navigationOptions = {
    title: 'Manage Publishers',
};

constructor() {
    super()
    this.state = {
        isLoading: true,
        selectedPublishers1:[],
        publishersByCategory: [],
        publishersByClient: [],
        publishersByGroup: [],
        dataSource:[]
    }
}

componentDidMount() 
{
    const base64 = require('base-64');
    fetch('APIURL'+this.props.navigation.state.params.id, 
    {
        method: 'GET',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
            "Authorization": "Basic " + base64.encode("ABC:XYZ")
        }
    }).then((response) => response.json()
    )
        .then((responseJson) => {
            this.setState({
                categories: responseJson.PublisherByCategory,
            }, function () {

        });
    })
    .catch((error) => {
        console.log("error in category");
        console.log(error);
    });


}

onSelectedPublishersByCategoryChange = (publishersByCategory) => {
    console.log(publishersByCategory);
    this.setState({ publishersByCategory });
}



render() {
    const { navigate } = this.props.navigation;
    if (this.state.isLoading) {
    return (
    <View style={{ flex: 1, paddingTop: 20 }}>
      <ActivityIndicator />
    </View>
  );
}
return ([
  <View style={{flex: 1,paddingTop: (Platform.OS === 'ios') ? 20 : 20, padding: 5}}>
    <Text style={{ padding: 5, fontSize: 35, backgroundColor: '#2196F3', marginBottom: 7 }}>
        Manage Publishers
    </Text>
    <MultiSelect
      items={this.state.categories}
      uniqueKey="id"
      ref={(component) => { this.multiSelect = component }}
      onSelectedItemsChange={this.onSelectedPublishersByCategoryChange}
      selectedItems={this.state.publishersByCategory}
      selectText="Publishers by Category"
      searchInputPlaceholderText="Search Publisher..."
      onChangeInput={ (text)=> console.log(text)}
      altFontFamily="ProximaNova-Light"
      tagRemoveIconColor="#CCC"
      tagBorderColor="#CCC"
      tagTextColor="#CCC"
      selectedItemTextColor="#CCC"
      selectedItemIconColor="#CCC"
      itemTextColor="#000"
      displayKey="name"
      searchInputStyle={{ color: '#CCC' }}
      submitButtonColor="#CCC"
      submitButtonText="Submit"
    />
  </View>,
  <View>
     {this.multiSelect.getSelectedItemsExt(selectedItems)} 
  </View>
 ]);
}
}
});

 module.exports = manage_publishers;

请看看这个并提供解决方案,我会非常感激.

Please have a look at this and provide me solution, I'll be very thankful .

推荐答案

我遇到了同样的问题,我解决了添加 AND 条件:

I had that same issue, and I solved adding a AND condition:

{this.multiSelect && this.multiSelect.getSelectedItemsExt(selectedItems)}

{this.multiSelect && this.multiSelect.getSelectedItemsExt(selectedItems)}

这篇关于React-native-multiple-select:无法读取未定义的属性“getSelectedItemsExt"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆