更新: | 2024-05-20 |
---|---|
作者: | @voluntas |
バージョン: | 2024.1 |
URL: | https://voluntas.github.io/ |
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
import { useEffect, useRef } from "react" | |
export const useOnClickOutside = <T extends HTMLDivElement>(handler?: (event: MouseEvent | TouchEvent) => void) => { | |
const ref = useRef<T>(null) | |
useEffect(() => { | |
const listener = (event: MouseEvent | TouchEvent) => { | |
if (handler) { | |
if (!ref.current || ref.current.contains(event.target as Node)) { | |
return | |
} |
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
import { useEffect, useRef, useState } from "react" | |
interface UseResizeObserverReturns<T> { | |
ref: React.RefObject<T> | |
width: number | |
height: number | |
} | |
const useResizeObserver = <T>(): UseResizeObserverReturns<T> => { | |
const ref = useRef<T>(null) |
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 throttle = (callback) => { | |
let throttled = false | |
return () => { | |
if(throttled) return | |
throttled = true | |
window.setTimeout(()=>{throttled = false}, 500) | |
callback() | |
} | |
} |
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
import { useLayoutEffect, useState } from "react" | |
let animationFrameID = 0 | |
export const useIntersectionObserver = ( | |
ref: React.RefObject<HTMLElement>, | |
options?: IntersectionObserverInit | |
): IntersectionObserverEntry | undefined => { | |
const [entry, setEntry] = useState<IntersectionObserverEntry>() | |
useLayoutEffect(() => { | |
const element = ref.current |
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 done = false | |
const LazyComponent = () => { | |
if (!done) { | |
throw new Promise(resolve => { | |
window.setTimeout(() => { | |
done = true | |
resolve() | |
}, 3000) | |
}) | |
} |
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
workflows: | |
version: 2 | |
hogehoge: | |
jobs: | |
- deploy: | |
filters: | |
branches: | |
only: | |
- master | |
version: 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
# 構文 | |
npm install github:[user|organization]/[repository]#[branch|tag|commit] | |
# 例文 | |
npm install github:hrdtbs/hello-world#build | |
## *私が試した限りではbranch、tag、commitはorでした。要確認。 | |
# セマンティックバージョニング | |
npm install github:[user|organization]/[repository]#semver:^X.Y.Z |
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: 2.1 | |
executors: | |
golang: | |
docker: | |
- image: circleci/golang:latest | |
environment: | |
GO111MODULE: "on" | |
commands: |
OlderNewer