Skip to content

Instantly share code, notes, and snippets.

View jayantbh's full-sized avatar
🟣
Building middlewarehq.com

Jayant Bhawal jayantbh

🟣
Building middlewarehq.com
View GitHub Profile
@jayantbh
jayantbh / use-frame.js
Created June 21, 2020 16:10
useFrame hook - takes a function, and throttles it using requestAnimationFrame
/* eslint-env browser */
import {useRef} from 'react';
export const useFrame = <T = any>(fn: (...args: T[]) => any) => {
const frameRef = useRef();
return (..._args: T[]) => {
frameRef.current && cancelAnimationFrame(frameRef.current);
frameRef.current = requestAnimationFrame(() => fn(..._args));
@jayantbh
jayantbh / tailwind.config.js
Created June 15, 2021 15:33
Tailwind Empty Pseudo-Selector Variant
const plugin = require("tailwindcss/plugin");
// tested for tailwindcss 2.1.2
module.exports = {
// other config
variants: {
extend: {
// other variant extensions
display: ["empty"],