sickdyd / react-search-autocomplete

A search box that filters the provided array of objects
https://sickdyd.github.io/react-search-autocomplete
MIT License
222 stars 85 forks source link

Question: I would like to know how to differentiate several <ReactSearchAutocomplete /> in a single component #75

Closed pedromaironi closed 2 years ago

pedromaironi commented 2 years ago

I have several inputs inside a form. 3 of them are react-search-autocomplete. So, I had the question how I could identify each combobox. If with an id or a name... I don't want to have to create an OnHandleSearch for that I have created on 5 or 10 forms

  const [state, setState] = useState({
    product: "",
    discount: 0,
    price: 0,
    tax: "",
    description: "",
    amount: 0,
    total: 0,
  });

I'm waiting for manage the autocomplete's components like this
  const handleChange = (e) => {
    setState({
      ...state,
      [e.target.name]: e.target.value,
    });
  };

image

Thank u!

pedromaironi commented 2 years ago

Black: <ReactSearchAutocomplete /> Blue: Simple input

sickdyd commented 2 years ago

Sorry, multiple search boxes in one page are not yet supported, there could be some issues.

Anyway this seems more likely an issue with how to manage your code rather than how to use the component itself. Also I'm not a 100% sure what the problem is 🤔