This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let isOn = true; | |
const handleClick = () => { | |
isOn = !isOn; | |
}; | |
<button | |
onClick={handleClick} | |
style={{ backgroundColor: isOn ? 'green' : 'red' }} | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const items = [ | |
{ | |
img: 'a.png', | |
title: 'Title 1', | |
description: 'Description 1' | |
}, | |
{ | |
img: 'b.png', | |
title: 'Title 2', | |
description: 'Description 2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Parent component | |
<Item img='a.png' title='title 1' description='Description 1'></Item> | |
<Item img='b.png' title='title 2' description='Description 2'></Item> | |
<Item img='c.png' title='title 3' description='Description 3'></Item> | |
<Item img='d.png' title='title 4' description='Description 4'></Item> | |
// Child component | |
<div> | |
<img src={img} /> | |
<h3>{title}</h3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.4.1/workbox-sw.js') | |
workbox.routingl.registerRoute( | |
({request}) => request.destination === "image", | |
// This will try to load the images from the network first, then fallback to the cached | |
new workbox.strategies.NetworkFirst() | |
// If we want to use the cashed content first, we could use: | |
// new workbox.strategies.CasheFirst() | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Hello World", | |
"short_name": "Hello World", | |
"start_url" : "?home=true", | |
"icons":[ | |
{ | |
"src":"icons/manifest-icon-192.png", | |
"sizes":"192x192", | |
"type":"image/png", | |
"purpose":"maskable any" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Hi WPA</title> | |
<link rel="manifest" href="manifest.json"> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": "*", | |
"Action": [ | |
"s3:GetObject" | |
], | |
"Resource": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs.readFile(“./usr/myfile.txt”, function myfunc (err, data) { | |
console.log(“Task done”); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function whatever(handleData){ | |
getData(url , data=>handleData(data)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let products=[{name:'RTX 3090',price:1499},{name:'Apple Stand',price:1000}] | |
let totalPrice = 0 | |
products.forEach(product=> totalPrice += product.price) | |
return totalPrice |
NewerOlder