Need some assistance with an alert message functionality. I have a button labeled Checkout, and when clicked, it should clear the cart and display an alert. At present, the individual functions work as expected - calling emptyCart()
works fine, and calling notify()
with just toast("Wow so easy!")
also works smoothly. However, when both functions are called together, only the emptyCart()
function seems to execute successfully because it removes all items, including the button itself. As a result, the toast("Wow so easy!")
does not get displayed since the button is no longer there. I'm looking to resolve this issue by displaying the alert message and clearing all items from the wishlist. Any help would be greatly appreciated.
Sharing my current code below:
import React, { useEffect } from 'react';
import { Button, Container, Col, Row, Table } from 'react-bootstrap';
import { useCart } from 'react-use-cart';
import { useThemeHook } from '../GlobalComponents/ThemeProvider';
// Additional imports...
const Cart = () => {
// Component logic...
};
export default Cart;