You do this.
const handleEvent = e => {
setState(e.target.value);
console.log(state);
}
import { RefObject, useEffect, useState } from "react"; | |
import ResizeObserver from "resize-observer-polyfill"; | |
type BoundingRect = Omit<DOMRectReadOnly, "toJSON">; | |
export function useResizeObserver<T extends HTMLElement>(target: RefObject<T>) | |
{ | |
const [state, setState] = useState<BoundingRect>({ bottom: 0, height: 0, left: 0, right: 0, top: 0, width: 0, x: 0, y: 0 }); |
import { FetchBaseQueryError } from '@rtk-incubator/rtk-query/dist'; | |
/** | |
* Default tags used by the cacher helpers | |
*/ | |
const defaultTags = ["UNAUTHORIZED", "UNKNOWN_ERROR"] as const; | |
type DefaultTags = typeof defaultTags[number]; | |
function concatErrorCache<T, ID>( | |
existingCache: CacheList<T, ID>, |
import { useRef, useCallback} from 'react'; | |
/** | |
* Accepts a given callback, and provides a new callback with a stable reference, | |
* which will itself always call the latest version of the provided callback. | |
* Useful for dealing with third party components that use stale closures. | |
* @param callback - the original callback desired to be called | |
* @returns A new callback with a stable reference, which when called, | |
* calls the latest provided callback | |
* @deprecated - This implementation may have future issues in concurrent mode, as it mutates |
export type Entries<T> = { | |
[K in keyof T]: [K, T[K]]; | |
}[keyof T][]; | |
/** | |
* Helper to use `Object.entries` while retaining key type information. | |
* Input object should be cast `as const` for maximum effectiveness. | |
*/ | |
export function objEntries<T extends Record<string, unknown>>(obj: T): Entries<T> { | |
return Object.entries(obj) as Entries<T>; |