Skip to content

Instantly share code, notes, and snippets.

View soulr344's full-sized avatar

Prajwal Pokhrel soulr344

View GitHub Profile
@soulr344
soulr344 / Input.tsx
Last active July 4, 2024 13:56
UPPERCASE only input using react hook form that retains cursor position.
import {
ComponentProps,
KeyboardEvent,
useLayoutEffect,
useRef,
useState,
} from "react";
import { Control, FieldValues, Path, useController } from "react-hook-form";
const getCursorPosition = (e: React.KeyboardEvent<HTMLInputElement>) => {