doc: add removeFromBasket function
This commit is contained in:
1 parent
f363deead4
commit
0253490cd3
1 file changed
+9
-1
@@ -1,7 +1,15 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useStateValue } from "../redux/StateProvider";
|
||||||
import "./CheckoutProduct.css";
|
import "./CheckoutProduct.css";
|
||||||
|
|
||||||
function CheckoutProduct({ id, image, title, price, rating }) {
|
function CheckoutProduct({ id, image, title, price, rating }) {
|
||||||
|
const [{ bakset }, dispatch] = useStateValue();
|
||||||
|
const removeFromBasket = () => {
|
||||||
|
dispatch({
|
||||||
|
type: "REMOVE_FROM_BASKET",
|
||||||
|
id: id,
|
||||||
|
});
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<section className="checkoutProduct">
|
<section className="checkoutProduct">
|
||||||
<img className="checkoutProduct__image" src={image} alt="product info" />
|
<img className="checkoutProduct__image" src={image} alt="product info" />
|
||||||
@@ -19,7 +27,7 @@ function CheckoutProduct({ id, image, title, price, rating }) {
|
|||||||
<p>🌟</p>
|
<p>🌟</p>
|
||||||
))}
|
))}
|
||||||
</article>
|
</article>
|
||||||
<button>Remove from Basket</button>
|
<button onClick={removeFromBasket}>Remove from Basket</button>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user