First of all i take select. Inside the select tag I have mapped category showSearch using input field but data is not found when searching.
My code is here..
<Select
bordered={false}
placeholder="Search to Select"
size="large"
showSearch
className="form-select m-3 w-96 border"
onChange={(value) => {
setCategory(value);
}}
>
{categories?.map((c) => (
<Option key={c._id} value={c._id}>
{c.name}
</Option>
))}
</Select>
Seems like you haven't added the onSearch
prop, try adding it as:
<Select
bordered={false}
placeholder="Search to Select"
size="large"
showSearch
className="form-select m-3 w-96 border"
onSearch={handleSearch}
onChange={(value) => {
setCategory(value);
}}
>
{categories?.map((c) => (
<Option key={c._id} value={c._id}>
{c.name}
</Option>
))}
</Select>
And a function to handle search:
async function handleSearch(userInput){
const response = await axios.get("https://test.com",{searchValue: userInput });
setCategories(response.data);
}