admin管理员组文章数量:1406052
I am storing user text input into states like so
<TextInput
placeholder = "Hello"
onChangeText = {(text) => this.setState({greeting: text})}
/>
I want to do a similar thing using react-native-modal-dropdown.
<ModalDropdown
style = {styles.enterSearch}
options = {this.state.gasOptions}
onSelect {(renderButtonText) => this.setState({gas: renderButtonText})}
/>
With this code I can select what option I want but I cannot find a way to get the value of the text option selected.
Any help would be great.
I am storing user text input into states like so
<TextInput
placeholder = "Hello"
onChangeText = {(text) => this.setState({greeting: text})}
/>
I want to do a similar thing using react-native-modal-dropdown.
<ModalDropdown
style = {styles.enterSearch}
options = {this.state.gasOptions}
onSelect {(renderButtonText) => this.setState({gas: renderButtonText})}
/>
With this code I can select what option I want but I cannot find a way to get the value of the text option selected.
Any help would be great.
Share Improve this question edited Jul 10, 2018 at 21:22 paulgio asked Jul 10, 2018 at 21:04 paulgiopaulgio 7222 gold badges8 silver badges23 bronze badges1 Answer
Reset to default 5For some reason you have to put String in front of the value for it to actually read it correctly. This took me a while to figure out so I hope it helps someone else out.
<ModalDropdown
style = {styles.enterSearch}
options = {this.state.gasOptions}
onSelect {(value) => this.setState({gas: (String(this.state.gasOptions[value]))})}
/>
本文标签: javascriptGetting value selected when using reactnativemodaldropdownStack Overflow
版权声明:本文标题:javascript - Getting value selected when using react-native-modal-dropdown - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744920677a2632275.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论