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

useLayoutEffect

StarStarStarStar

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

StarStarStarStar

useCallback

StarStarStarStar

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

StarStarStarStar

useMemo

StarStarStarStar

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

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

useDebugValue

StarStarStarStar

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

StarStarStarStar

useOpaqueIdentifier

StarStarStarStar

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

StarStarStarStar

useSyncExternalStore

StarStarStarStar

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

StarStarStarStar

useCacheRefresh

StarStarStarStar

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

StarStarStarStar

useRef

StarStarStarStar

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

StarStarStarStar

useEffect

StarStarStarStar

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

StarStarStarStar

useImperativeHandle

StarStarStarStar

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

StarStarStarStar

useDeferredValue

StarStarStarStar

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

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

useInsertionEffect

StarStarStarStar

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

StarStarStarStar

useState

StarStarStarStar

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

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

useTransition

StarStarStarStar

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

StarStarStarStar

useSelector

StarStarStarStar

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

StarStarStarStar

useReducer

StarStarStarStar

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

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.