Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
373 views
in Technique[技术] by (71.8m points)

react native - onDropdownClose() is not a function error

I have used this package react-native-dropdown-autocomplete several times and there on this particular page I do not understand the bug ...

I initialize onDropdownClose like in the documentation in a function:

handleSelectItem = async (type, item, index) => { const {onDropdownClose} = this.props; onDropdownClose (); };

Then in the render I am still the documentation and I do this:

const {scrollToInput, onDropdownClose, onDropdownShow} = this.props;

and in autocomplete I call it like this:

<Autocomplete
   key={shortid.generate()}
   containerStyle={{margin: 0, padding: 0, borderBottomColor: 'transparent',}}
   inputStyle={{ width: '80%', borderWidth: 1, backgroundColor: '#FFF', opacity: 0.9, borderColor: '#F78400'}}
    placeholder={i18n.t("tickets.event")}
    placeholderColor="#F78400"
    pickerStyle={styles.autocompletePicker}
    scrollStyle={styles.autocompleteScroll}
    scrollToInput={ev => {}}
    handleSelectItem={(item, id) => this.handleSelectItem(item, id)}
    onDropdownClose={() => onDropdownClose()}
    onDropdownShow={() => onDropdownShow()}              
    data={this.state.displayArray}
    minimumCharactersCount={2}
    highlightText
    valueExtractor={item => item.name}
    rightContent
    rightTextExtractor={item => item.properties}
/>

I get :

TypeError: _onDropdownClose is not a function. (In '_onDropdownClose()', '_onDropdownClose' is undefined)

Can you help me understand why in this particular screen I can't get this dropdown function to work?

I feel lost in my code and really need to understand. Thank you for your time


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...