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

passing suggestions directly into Autosuggest? #71

Closed
matthewmueller opened this issue Oct 5, 2015 · 4 comments
Closed

passing suggestions directly into Autosuggest? #71

matthewmueller opened this issue Oct 5, 2015 · 4 comments

Comments

@matthewmueller
Copy link

Is it possible to do something like this:

<Autosuggest suggestions={["a", "b", "c"]} />

this is helpful for systems like redux, where the suggestions would be in a store

@ksmth
Copy link

ksmth commented Oct 9, 2015

@matthewmueller:
As a temporary fix:

class ControlledAutosuggest extends Autosuggest {
  componentWillReceiveProps(props: Object) {
    super.componentWillReceiveProps(props);
    this.showSuggestions(props.value || '', props.suggestions);
  }
  showSuggestions(input, suggestions) {
    if (!this.props.showWhen(input)) {
      this.setSuggestionsState(null);
    } else {
      this.setSuggestionsState(suggestions || this.props.suggestions);
    }
  }
}

ControlledAutosuggest.propTypes = {
  ...Autosuggest.propTypes,
  suggestions : PropTypes.array
};

@moroshko
Copy link
Owner

moroshko commented Oct 9, 2015

@matthewmueller I'm rebuilding react-autosuggest at the moment to support flux architectures including redux. Check out this redux example. You are more than welcome to contribute to the design of the new API.

@ksmth Thanks for the suggested workaround.

@moroshko
Copy link
Owner

As I mentioned above, flux architecture will be supported in 3.0.

@moroshko
Copy link
Owner

@matthewmueller @ksmth Just wanted to let you know that 3.0 alpha version is available on npm:

npm install [email protected] --save

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

No branches or pull requests

3 participants