This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-underscore-dangle */ | |
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
import { useMutation, UseMutationResult, useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query'; | |
type BaseFn = (...args: any[]) => unknown; | |
type FirstParameter<TFn extends BaseFn> = Parameters<TFn>[0] extends undefined ? void : Parameters<TFn>[0]; | |
type Procedure<TFn = BaseFn> = { | |
/** | |
* @deprecated - internal use only |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variables: | |
pnpm_config_cache: $(Pipeline.Workspace)/.pnpm-store | |
steps: | |
- task: Cache@2 | |
inputs: | |
key: 'pnpm | "$(Agent.OS)" | pnpm-lock.yaml' | |
path: $(pnpm_config_cache) | |
displayName: Cache pnpm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variables: | |
pnpm_config_cache: $(Pipeline.Workspace)/.pnpm-store | |
trigger: | |
- main | |
pool: | |
vmImage: ubuntu-latest | |
steps: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variables: | |
pnpm_config_cache: $(Pipeline.Workspace)/.pnpm-store | |
trigger: | |
- main | |
pool: | |
vmImage: ubuntu-latest | |
steps: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
// To avoiding Use Effect Getting Called Twice | |
// See https://dev.to/ag-grid/react-18-avoiding-use-effect-getting-called-twice-4i9e | |
export const useMount = (effect: () => void | (() => void)) => { | |
const destroyFunc = React.useRef<void | (() => void)>(); | |
const effectCalled = React.useRef(false); | |
const renderAfterCalled = React.useRef(false); | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
const [val, setVal] = React.useState<number>(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import useApi from './useApi'; | |
import { useMount } from './useMount'; | |
type MutationOptions<TData, TError> = { | |
onError?: (err: TError, config: MutationConfig) => void; | |
onSuccess?: (data: TData, config: MutationConfig) => void; | |
}; | |
type MutationConfig = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
import { waitFor, renderHook } from '@testing-library/react'; | |
import { AxiosError } from 'axios'; | |
import nock from 'nock'; | |
import useQuery from './useQuery'; | |
// mock useAuth | |
vi.mock('./useAuth', () => ({ | |
default: vi.fn(() => ({ | |
isAuthenticated: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createQueryFn(baseUrl: string): QueryFunction { | |
return async ({queryKey}) => { | |
const path = | |
typeof queryKey === 'string' ? queryKey : queryKey[0] + qs(queryKey[1]) | |
const res = await fetch(baseUrl + path) | |
if (!res.ok) throw new Error(await res.json()) | |
return res.json() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function useDebounce(value, delay) { | |
// State and setters for debounced value | |
const [debouncedValue, setDebouncedValue] = useState(value); | |
useEffect( | |
() => { | |
// Update debounced value after delay | |
const handler = setTimeout(() => { | |
setDebouncedValue(value); | |
}, delay); | |
// Cancel the timeout if value changes (also on delay change or unmount) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createContext, useContext, useMemo, ConsumerProps, ReactNode } from 'react' | |
interface Value { | |
mode: 'dark' | 'light'; | |
setMode: (mode: 'dark' | 'light') => void; | |
compact: boolean; | |
setCompact: (compact: boolean) => void; | |
} | |
const Context = createContext<Value | null>(null) |
NewerOlder