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
* { | |
min-width: 0; | |
font: inherit; | |
} | |
*, *::before, *::after { | |
box-sizing: border-box; | |
} | |
img, video, svg { |
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 * as React from "react"; | |
export function isTouchEvent({ nativeEvent }) { | |
return window.TouchEvent | |
? nativeEvent instanceof TouchEvent | |
: "touches" in nativeEvent; | |
} | |
export function isMouseEvent(event) { | |
return event.nativeEvent instanceof MouseEvent; |
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 * as React from "react"; | |
const isShallowEqual = (object1, object2) => { | |
const keys1 = Object.keys(object1); | |
const keys2 = Object.keys(object2); | |
if (keys1.length !== keys2.length) { | |
return false; | |
} |
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 * as React from "react"; | |
export default function useIsClient() { | |
const [isClient, setIsClient] = React.useState(false); | |
React.useEffect(() => { | |
setIsClient(true); | |
}, []); | |
return isClient; |
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 * as React from "react"; | |
const dispatchStorageEvent = (key, newValue) => { | |
window.dispatchEvent(new StorageEvent("storage", { key, newValue })); | |
}; | |
const setItem = (key, value) => { | |
const stringifiedValue = JSON.stringify(value); | |
window.sessionStorage.setItem(key, stringifiedValue); | |
dispatchStorageEvent(key, stringifiedValue); |
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 * as React from "react"; | |
const dispatchStorageEvent = (key, newValue) => { | |
window.dispatchEvent(new StorageEvent("storage", { key, newValue })); | |
}; | |
const setItem = (key, value) => { | |
const stringifiedValue = JSON.stringify(value); | |
window.localStorage.setItem(key, stringifiedValue); | |
dispatchStorageEvent(key, stringifiedValue); |
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 * as React from "react"; | |
export function useGeolocation(options = {}) { | |
const [state, setState] = React.useState({ | |
loading: true, | |
accuracy: null, | |
altitude: null, | |
altitudeAccuracy: null, | |
heading: null, | |
latitude: 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
import * as React from 'react'; | |
React.useEffectEvent = React.experimental_useEffectEvent; | |
export function useCountdown(endTime, options) { | |
const [count, setCount] = React.useState(null); | |
const intervalIdRef = React.useRef(null); | |
const handleClearInterval = () => { | |
window.clearInterval(intervalIdRef.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
import * as React from 'react'; | |
React.useEffectEvent = React.experimental_useEffectEvent; | |
const initialState = { | |
error: undefined, | |
data: undefined, | |
}; | |
const reducer = (state, action) => { |
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 * as React from "react"; | |
function throttle(cb, ms) { | |
let lastTime = 0; | |
return () => { | |
const now = Date.now(); | |
if (now - lastTime >= ms) { | |
cb(); | |
lastTime = now; | |
} |
NewerOlder