Support Ukraine ๐Ÿ‡บ๐Ÿ‡ฆ
๐Ÿ‡บ๐Ÿ‡ฆ
Help Provide Humanitarian Aid to Ukraine.
React
Learn
Reference
Community
Blog

    react@18.2.0

  • Hooks
    • useCallback
    • useContext
    • useDebugValue
    • useDeferredValue
    • useEffect
    • useId
    • useImperativeHandle
    • useInsertionEffect
    • useLayoutEffect
    • useMemo
    • useReducer
    • useRef
    • useState
    • useSyncExternalStore
    • useTransition
  • Components
    • <Fragment> (<>)
    • <Profiler>
    • <StrictMode>
    • <Suspense>
  • APIs
    • createContext
    • forwardRef
    • lazy
    • memo
    • startTransition
  • react-dom@18.2.0

  • Components
    • Common (e.g. <div>)
    • <input>
    • <option>
    • <progress>
    • <select>
    • <textarea>
  • APIs
    • createPortal
    • flushSync
    • findDOMNode
    • hydrate
    • render
    • unmountComponentAtNode
  • Client APIs
    • createRoot
    • hydrateRoot
  • Server APIs
    • renderToNodeStream
    • renderToPipeableStream
    • renderToReadableStream
    • renderToStaticMarkup
    • renderToStaticNodeStream
    • renderToString
  • Legacy APIs

  • Legacy React APIs
    • Children
    • cloneElement
    • Component
    • createElement
    • createFactory
    • createRef
    • isValidElement
    • PureComponent

Is this page useful?

API Reference
Hooks

useRef

useRef is a React Hook that lets you reference a value thatโ€™s not needed for rendering.

const ref = useRef(initialValue)
  • Reference
    • useRef(initialValue)
  • Usage
    • Referencing a value with a ref
    • Manipulating the DOM with a ref
    • Avoiding recreating the ref contents
  • Troubleshooting
    • I canโ€™t get a ref to a custom component

Reference