The library is great but I was in need of a select widget that could asynchronously fetch options from the server. So I made a component for it and tried to stick to the same coding style as much as I could. I've commented the propTypes as well as added an example of how it is used in the comments at the top of the file. Let me know if you don't agree with the way something has been done and I can update it.
Here is the usage example:
import React from 'react';
import { GiftedForm } from 'react-native-gifted-form';
const MyTypeaheadComponent = React.createClass({
render() {
return (
<GiftedForm.SelectTypeaheadWidget
title='Search'
name='search'
placeholder='Type to search...'
noResultsText='Sorry, we couldnt find any results...'
fetchOnMount={false}
onSearch={this.handleSearch.bind(this)}
onSearchError={error => { console.log(error); }}
/>
)
},
handleSearch(text, callback) {
// here you would do ajax call or something along those lines
callback(null, [
{ id: 1, value: 1, label: 'Option 1' },
{ id: 2, value: 2, label: 'Option 2' },
{ id: 3, value: 3, label: 'Option 3' },
]);
},
});
The library is great but I was in need of a select widget that could asynchronously fetch options from the server. So I made a component for it and tried to stick to the same coding style as much as I could. I've commented the propTypes as well as added an example of how it is used in the comments at the top of the file. Let me know if you don't agree with the way something has been done and I can update it.
Here is the usage example: