Packages
react
hooks
useWishlist

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/FunctionDescription
itemsAn array of strings representing items in the wishlist.
wishlistThe wishlist object containing wishlist details.
wishlistLoadingA boolean indicating whether the wishlist is currently loading.
addItemA function to add items to the wishlist.
removeItemA function to remove items from the wishlist.
clearItemsA function to clear all items from the wishlist.