Skip to content

Instantly share code, notes, and snippets.

View GalindoSVQ's full-sized avatar
🎯
Focusing

Antonio Galindo GalindoSVQ

🎯
Focusing
View GitHub Profile
* {
min-width: 0;
font: inherit;
}
*, *::before, *::after {
box-sizing: border-box;
}
img, video, svg {
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;
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;
}
import * as React from "react";
export default function useIsClient() {
const [isClient, setIsClient] = React.useState(false);
React.useEffect(() => {
setIsClient(true);
}, []);
return isClient;
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);
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);
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,
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);
import * as React from 'react';
React.useEffectEvent = React.experimental_useEffectEvent;
const initialState = {
error: undefined,
data: undefined,
};
const reducer = (state, action) => {
import * as React from "react";
function throttle(cb, ms) {
let lastTime = 0;
return () => {
const now = Date.now();
if (now - lastTime >= ms) {
cb();
lastTime = now;
}