Skip to content

Instantly share code, notes, and snippets.

View rohmanhm's full-sized avatar
💪
yes

Rohman HM rohmanhm

💪
yes
View GitHub Profile

Filename

use{Service}{Action}.mutation.ts

Code

import { MutationOptions, useMutation } from '@tanstack/react-query';

import { PayloadType } from '@/types/api';

Filename

use{Service}{Action}.query.ts

Code

import { QueryObserverOptions, useQuery } from '@tanstack/react-query';

import { DataShape } from '@/types/api';
@rohmanhm
rohmanhm / use-debounced-effect.ts
Last active May 6, 2024 12:28
useDebouncedEffect to delay the React.useEffect to immediately being executed. It is useful to save some performance while user changing the state of the component.
import { DependencyList, useEffect } from 'react';
export function useDebouncedEffect(
fn: () => void,
deps: DependencyList,
delay: number
) {
useEffect(() => {
const timer = setTimeout(() => {
fn();