useWishlist
The useWishlist hook provides access to wishlist-related functionality such as adding, removing, and clearing items from the wishlist.
Usage
To use the useWishlist hook, you need to wrap your component tree with the WishlistProvider component provided by this library. Then, you can call the useWishlist hook within any descendant component.
import React from 'react';
import { WishlistProvider, useWishlist } from '@airsoko/wishlist';
function MyComponent() {
const { items, addItem, removeItem, clearItems, wishlist, wishlistLoading } = useWishlist();
// Your component logic here...
return (
// Your JSX here...
);
}
export default function App() {
return (
<WishlistProvider>
<MyComponent />
</WishlistProvider>
);
}
Parameters
| Property/Function | Description |
|---|---|
| items | An array of strings representing items in the wishlist. |
| wishlist | The wishlist object containing wishlist details. |
| wishlistLoading | A boolean indicating whether the wishlist is currently loading. |
| addItem | A function to add items to the wishlist. |
| removeItem | A function to remove items from the wishlist. |
| clearItems | A function to clear all items from the wishlist. |