| display: none | visibility: hidden | opacity: 0 | |
|---|---|---|---|
| Remove from document flow | Y | N | N |
| Reflow | Y | N | N |
| Repaint | Y | Y | / |
| Reversed on child element | N | Y | N |
| transition | N | Y | Y |
| Self-attached events are triggerable | N | N | Y |
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> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
| <style> | |
| @keyframes cursorBlink { | |
| 0% { | |
| border-right-color: initial; |
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 { useMemo, useRef } from 'react'; | |
| import { useLocation, useNavigate } from 'react-router'; | |
| const useUrlState = <S extends Record<string, string>>( | |
| initialState: S, | |
| navigateMode: 'push' | 'replace' = 'push', | |
| ) => { | |
| const location = useLocation(); | |
| const navigate = useNavigate(); |
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 { useEffect, useRef, useState } from 'react'; | |
| type RotatedImage = { | |
| src: string; | |
| width: number; | |
| height: number; | |
| } | null; | |
| let canvas: HTMLCanvasElement | null = null; | |
| let canvasCtx2D: CanvasRenderingContext2D | null = null; |
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 { useEffect, useRef } from 'react'; | |
| const usePrevious = (value) => { | |
| const ref = useRef(); | |
| useEffect(() => { | |
| ref.current = value; | |
| }, [value]); | |
| return ref.current; |
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 { useEffect, useState } from 'react'; | |
| const Router = ({ routes, defaultComponent }) => { | |
| const [currentPath, setCurrentPath] = useState( | |
| () => window.location.pathname, | |
| ); | |
| useEffect(() => { | |
| const onLocationChange = () => { | |
| setCurrentPath(window.location.pathname); |
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
| console.time('Time'); | |
| const fs = require('fs'); | |
| const readline = require('readline'); | |
| void (async () => { | |
| const rl = readline.createInterface({ | |
| input: fs.createReadStream('test.json'), | |
| crlfDelay: Infinity, | |
| }); |
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
| const enum StepKey { | |
| next = 'next', | |
| throw = 'throw', | |
| } | |
| const generator2async = < | |
| P extends any[], | |
| T = unknown, | |
| TReturn = any, | |
| TNext = unknown, |
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
| // Serial execution of multiple functions | |
| const compose = (...funcs) => | |
| funcs.reduce( | |
| (a, b) => | |
| (...args) => | |
| a(b(...args)), | |
| ); | |
| export const createStore = (reducer, enhancer) => { | |
| if (typeof enhancer === 'function') { |
NewerOlder