Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const GlobalState = () => {
const products = [
{ id: "p1", title: "Gaming Mouse", price: 29.99 },
{ id: "p2", title: "Harry Potter 3", price: 9.99 },
{ id: "p3", title: "Used plastic bottle", price: 0.99 },
{ id: "p4", title: "Half-dried plant", price: 2.99 }
];
const [cartState, dispatch] = useReducer(shopReducer, { cart: [] });
const addProductToCart = product => {
dispatch({ type: ADD_PRODUCT, product: product });
};
const removeProductFromCart = productId => {
dispatch({ type: REMOVE_PRODUCT, productId: productId });
};
return html`