Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectTypeaheadWidget #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

finnfiddle
Copy link

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
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