Skip to content

SelectTypeaheadWidget - #79

Open
finnfiddle wants to merge 2 commits into
FaridSafi:masterfrom
finnfiddle:master
Open

finnfiddle wants to merge 2 commits into
FaridSafi:masterfrom
finnfiddle:master

Conversation

@finnfiddle

Copy link
Copy Markdown

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' },
    ]);
  },

});

@finnfiddle

Copy link
Copy Markdown
Author

any feedback on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant