Skip to content

Instantly share code, notes, and snippets.

@kivircik-parantez
Created December 30, 2022 22:04
Show Gist options
  • Save kivircik-parantez/b081e7cd65542435484d20c0725759ef to your computer and use it in GitHub Desktop.
Save kivircik-parantez/b081e7cd65542435484d20c0725759ef to your computer and use it in GitHub Desktop.
Event-specific logic
function ProductPage({ product, addToCart }) {
// ✅ Good: Event-specific logic is called from event handlers
function buyProduct() {
addToCart(product);
showNotification(`Added ${product.name} to the shopping cart!`);
}
function handleBuyClick() {
buyProduct();
}
function handleCheckoutClick() {
buyProduct();
navigateTo('/checkout');
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment