10

I want a autosuggest workflow like below. Instead of displaying numeric ID, say 123 in a text field, I want to show custom information.

enter image description here

While I can do the rest with React, I still need to do autocomplete. I have two requirements:

  1. When selected, provide a callback with rich data {id: 123, title:"Prince Hall", info:"123 Foo St"}
  2. Have custom rendering that allows me to reuse JSX templates

JQueryUI and Twitter autocompletes have both features. But their item rendering takes is string based, but I want to reuse JSX templates which are virtual-dom based. I dont want to duplicate/hardcode JSX templates with string templates.

2
  • could you please add the code you've started with and what's not working? As written, this question is too broad, it's asking to select a component for you, and then write the code. Commented Aug 5, 2015 at 12:46
  • @WiredPrairie, yes I had a feeling that this question is a hard to answer, recommendation question. I started with JqueryUI's and Twitter autocomplete and they had custom rendering, but with string templates only; and using React's virtual dom with string rendering was an uncrackable problem. Thats why I asked if there is any autocomplete that can play well with React rendering. Sorry the wording was too lazy. Commented Aug 5, 2015 at 13:17

3 Answers 3

15

Check out react-select. It is simple, beautiful and currently has the most Github stars. Live demo here.

Sign up to request clarification or add additional context in comments.

Comments

5

React-Autosuggest is a component that meets the requirements. It has custom rendering that works natively with React elements.

We can make it handle JS objects instead of plain strings.

  1. the onSuggestionSelected props is a callback to get the selected suggestion
  2. suggestionRenderer method takes suggestion and returns React markup

http://react-autosuggest.js.org/

Comments

0

Another powerful Auto-Complete/Auto-Suggest module is 'downshift' which has a wide variety of props for better customization. Different from react-select which opens as a select-box, downshift is a textbox which unhides a suggestion list of words as its value changes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.