This file contains hidden or 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
| // 🐢 custom hook - name starts with "use" (useMedium) | |
| useMedium(() => { | |
| const URI = "https://some-path-api"; | |
| // 🦄 custom hook can use any of the default | |
| // React hooks - this is NOT compulsory. | |
| useEffect(() => { | |
| fetch(URI) | |
| },[]) | |
| }) |
This file contains hidden or 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 CounterHooks() { | |
| const [count, setCount] = useState(0); | |
| const [time, setTime] = useState(new Date()) | |
| // 🐢 look here. | |
| useEffect(() => { | |
| console.log("useEffect first timer here.") | |
| }, [count]) | |
This file contains hidden or 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 CounterHooks() { | |
| const [count, setCount] = useState(0); | |
| const [time, setTime] = useState(new Date()) | |
| const handleClick = () => { | |
| setCount(count + 1); | |
| setTime(new Date()) | |
| } | |
| return ( |
This file contains hidden or 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 CounterHooks() { | |
| const [count, setCount] = useState(0); | |
| const handleClick = () => { | |
| setCount(count + 1); | |
| } | |
| return ( | |
| <div> | |
| <h3 className="center"> |
This file contains hidden or 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
| import React, { Component } from 'react'; | |
| class Counter extends Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| count: 1 | |
| }; | |
| } |
This file contains hidden or 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> | |
| <head> | |
| <style> | |
| header { | |
| background-image: paint(checker); | |
| } | |
| </style> | |
| </head> |
This file contains hidden or 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
| ... | |
| for (let y = 0; y < geom.height / size; y++) { | |
| for (let x = 0; x < geom.width / size; x++) { | |
| const color = colors[(x + y) % colors.length]; | |
| ctx.beginPath(); | |
| ctx.fillStyle = color; | |
| ctx.rect(x * size, y * size, size, size); | |
| ctx.fill(); | |
| } |
This file contains hidden or 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
| ... | |
| for (let y = 0; y < geom.height / size; y++) { | |
| for (let x = 0; x < geom.width / size; x++) { | |
| } | |
| } | |
| ... |
This file contains hidden or 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
| // declare the custom paint. | |
| class CheckerPaint { | |
| paint (ctx, geom, styleMap) { | |
| const colors = ["#f15278", "#fff"]; | |
| const size = 32; | |
| for (let y = 0; y < geom.height / size; y++) { | |
| for (let x = 0; x < geom.width / size; x++) { |
This file contains hidden or 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
| // declare the custom paint. | |
| class CheckerPaint { | |
| paint (ctx, geom, styleMap) { | |
| const colors = ["#f15278", "#fff"]; | |
| const size = 32; | |
| } |