Skip to content

Instantly share code, notes, and snippets.

View AbePlays's full-sized avatar
🎮
Enjoying EA FC 25

Abhishek Rawat AbePlays

🎮
Enjoying EA FC 25
View GitHub Profile
@AbePlays
AbePlays / Image.tsx
Created September 20, 2021 09:34
Custom Image Component
const ImgWithFallback = ({
src: string,
fallback: string,
type = 'image/webp',
...props
}) => {
return (
<picture>
<source srcSet={src} type={type} />
<img src={fallback} {...props} />
@AbePlays
AbePlays / useInterval.tsx
Created July 12, 2022 04:02
UseInterval
import { useEffect, useRef, useState } from 'react';
interface UseIntervalProps {
fn: () => void;
interval: number;
}
interface UseIntervalReturn {
active: boolean;
start: () => void;
import { useState, type TouchEvent } from 'react'
interface SwipeInput {
onSwipedLeft: () => void
onSwipedRight: () => void
}
interface SwipeOutput {
onTouchStart: (e: TouchEvent) => void
onTouchMove: (e: TouchEvent) => void