Skip to content

Instantly share code, notes, and snippets.

Cristian Marquez xthecapx

Block or report user

Report or block xthecapx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View currency.js
const currency = number => {
return number.toLocaleString(
"en",
{
style: "currency",
currency: "USD",
minimumFractionDigits: 2
}
);
}
View productDetailsRouter.jsx
import React from 'react';
import {products} from './products';
const ProductDetails = ({ name, match }) => {
const { params: { productId }} = match;
const product = products[productId];
return (
<div className="product-deatils">
View productDetailsReach.jsx
import React from 'react';
import {products} from './products';
const ProductDetails = ({ name, productId }) => {
const product = products[productId];
return (
<div className="product-deatils">
<h2>Product Details</h2>
View ProductDetailsEmpty.jsx
import React from 'react';
const ProductDetails = () => {
return (
<div className="product-deatils">
<h2>Product Details works!</h2>
</div>
)
};
View produtAlertProp.jsx
<ProductAlerts product={product} notify={onNotify} />
View onNotify.js
const onNotify = () => {
window.alert('You will be notified when the product goes on sale');
}
View ProductAlerts.jsx
import React from 'react';
import {products} from './products';
const ProductAlerts = ({ product }) => {
let productAlerts;
if (product.price > 700) {
productAlerts = <p><button>Notify Me</button></p>;
}
View share.jsx
<button onClick={share}>
 Share
</button>
View if_else_description.jsx
// in the function body
let description;
if (product.description) {
 description = <p>{`Description: ${product.description}`}</p>
}
// Bellow the h3 closing tag
{description}
View ternary.jsx
{product.description ? <p>{`Description: ${product.description}`}</p> : null}
You can’t perform that action at this time.