sickdyd / react-search-autocomplete

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

How can set default value in autocomplete ? #24

Closed alamtopan closed 2 years ago

alamtopan commented 3 years ago

How can set default value in autocomplete ?

on collection data data = [ {id: 0, name: 'alam'}, {id: 1, name: 'edit'}, {id: 3 name: 'asa'} ]

i want set default, with id = 0 or name alam ? its posible or not without selected first.

sickdyd commented 3 years ago

@alamtopan Hello!

You might want to take a look at this issue: https://github.com/sickdyd/react-search-autocomplete/issues/17

Codesandbox: https://codesandbox.io/s/distracted-fermat-zo6r8?file=/src/App.js

Let me know if it fixes your problem.

rughaanimskhan commented 2 years ago

Hey @alamtopan,

Unable to set default value on load, can you please help me for this issue?

bharath2612 commented 2 years ago

yes, how to set default value of input on load, please help :)

sickdyd commented 2 years ago

@rughaanimskhan @bharath2612 You can use the inputSearchString to set a default value:

<ReactSearchAutocomplete
 items={items}
 onSearch={handleOnSearch}
 inputSearchString="hello"
/>