Logo
Pattern

Discover published sets by community

Explore tens of thousands of sets crafted by our community.

ReactJS Hooks

20

Flashcards

0/20

Still learning
StarStarStarStar

useRef

StarStarStarStar

Returns a mutable ref object. Example: const myRef = useRef(initialValue);

StarStarStarStar

useImperativeHandle

StarStarStarStar

Customizes the instance value that is exposed when using ref. Example: useImperativeHandle(ref, () => ({ focus: () => { inputRef.current.focus(); } }), [inputRef]);

StarStarStarStar

useDebugValue

StarStarStarStar

Used to display a label for custom hooks in React DevTools. Example: useDebugValue(value);

StarStarStarStar

useMutableSource

StarStarStarStar

Used to access the state from an external, mutable source in a concurrent-safe way. Please note that this hook has been replaced by useSyncExternalStore in React 18.

StarStarStarStar

useReducer

StarStarStarStar

An alternative to useState which accepts a reducer function. Example: const [state, dispatch] = useReducer(reducer, initialState);

StarStarStarStar

useMemo

StarStarStarStar

Memorizes the calculated value. Example: const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);

StarStarStarStar

useLayoutEffect

StarStarStarStar

Runs synchronously after all DOM mutations. Example: useLayoutEffect(() => { measureLayout(); }, [dependencies]);

StarStarStarStar

useDeferredValue

StarStarStarStar

Defers the value until after the next render. Example: const deferredValue = useDeferredValue(value);

StarStarStarStar

useState

StarStarStarStar

Allows you to add state to functional components. Example: const [count, setCount] = useState(0);

StarStarStarStar

useInsertionEffect

StarStarStarStar

Used to inject styles into the DOM before layout occurs. Example: useInsertionEffect(() => { const sheet = new CSSStyleSheet(); sheet.replaceSync('* { transition: none; }'); });

StarStarStarStar

useOpaqueIdentifier

StarStarStarStar

Returns an object that is stable across server and client rendering, useful for generating unique IDs (deprecated, use useId instead).

StarStarStarStar

useCacheRefresh

StarStarStarStar

Triggers a refresh of cached data if updates are detected (experimental and not a part of the stable API).

StarStarStarStar

useEvent

StarStarStarStar

Enables stable event callbacks, preventing capture of values, props, and state (experimental in React 18). Example: const stableOnClick = useEvent(() => { console.log('clicked'); });

StarStarStarStar

useTransition

StarStarStarStar

Helps optimize the rendering of non-urgent updates. Example: const [isPending, startTransition] = useTransition();

StarStarStarStar

useContext

StarStarStarStar

Gives you access to the data in React Context. Example: const value = useContext(MyContext);

StarStarStarStar

useId

StarStarStarStar

Generates a unique and stable identifier. Example: const id = useId();

StarStarStarStar

useSyncExternalStore

StarStarStarStar

Subscribes to an external mutable source. Example: const state = useSyncExternalStore(store.subscribe, store.getState);

StarStarStarStar

useEffect

StarStarStarStar

Used to perform side effects in functional components. Example: useEffect(() => { document.title = `You clicked {count} times`;}, [count]);

StarStarStarStar

useSelector

StarStarStarStar

Used with React-Redux to efficiently select data from Redux store. Example: const data = useSelector(state => state.data);

StarStarStarStar

useCallback

StarStarStarStar

Memorizes a callback function. Example: const memoizedCallback = useCallback(() => { doSomething(a, b); }, [a, b]);

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.