Skip to main content
Version: 3.xx.xx

on-search-live-preview

localhost:3000/products
Live previews only work with the latest documentation.
import { useSelect } from "@pankod/refine-core";

interface ICategory {
id: number;
title: string;
}

const ProductCreate: React.FC = () => {
const { options, onSearch } = useSelect<ICategory>({
resource: "categories",
onSearch: (value) => [
{
field: "title",
operator: "contains",
value,
}
]
});

return (
<>
<p>
Filter:
<input onChange={(e) => onSearch(e.target.value)} />
</p>

<select>
{options?.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</select>
</>
);
};