Wishlist Provider
The Wishlist Provider component manages a wishlist by providing a context for adding, removing, and clearing items. It also handles fetching the initial wishlist data.
Usage
import React from "react";
import { WishlistProvider } from "@airsoko/react";
const App = () => {
return <WishlistProvider>{/* Your components that use wishlist context */}</WishlistProvider>;
};WishlistProvider Component
The WishlistProvider component is a context provider that manages wishlist-related state.
Props
| Name | Type | Description |
|---|---|---|
children | ReactNode | The child elements that will use the wishlist context. |
Functions
Available functions under WishlistProvider context
useWishlist Hook
The useWishlist hook allows components to access the wishlist context and its associated functions.
Example
import React from "react";
import { useWishlist } from "./WishlistProvider";
const MyComponent = () => {
const { wishlist, addItem, removeItem, clearItems, wishlistLoading } = useWishlist();
// Access and manage wishlist-related state
};Notes
- Ensure that the
WishlistProvidercomponent wraps the components that require access to wishlist-related state. - Use the
useWishlisthook within components to access and manage wishlist-related state.