useProducts Hook
Basic Setup & Configuration
1. How do I import the useProducts hook?
You can import the useProducts hook from @unbxd-ui/react-search-hooks
:
import { useProducts } from "@unbxd-ui/react-search-hooks";
The useProducts hook is designed to be used within the
UnbxdSearchCSRWrapper
or UnbxdSearchSSRWrapper
components.2. How do I access product count and pagination information?
The useProducts hook provides comprehensive pagination data:
const { products, start, numberOfProducts } = useProducts();
3. How do I know if the products are loading at the moment with useProducts hook?
The loading
property provided by the useProducts
hook indicates whether product data is currently being fetched. This can be used to control the display of loading indicators in your UI. Click here to view the loading property documentation.
4. Does the useProducts hook trigger data fetching?
The useProducts hook automatically provides product data when search state changes, but doesn't directly trigger API calls.
5. How can I determine if the products provided by the useProducts hook are for a SEARCH page or a CATEGORY page?
The useProducts
hook exports a productType
property. If productType
is SEARCH
, the products are from a search page. If it is CATEGORY
, the products are from a category page. Click here to view the productType property documentation.