mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 12:13:11 +00:00
Explain how null ends up in ref.current for React-managed refs (#5836)
* Update referencing-values-with-refs.md * Update src/content/learn/referencing-values-with-refs.md
This commit is contained in:
committed by
GitHub
parent
1dfc88fe46
commit
68f417a600
@@ -284,7 +284,7 @@ You also don't need to worry about [avoiding mutation](/learn/updating-objects-i
|
||||
|
||||
## Refs and the DOM {/*refs-and-the-dom*/}
|
||||
|
||||
You can point a ref to any value. However, the most common use case for a ref is to access a DOM element. For example, this is handy if you want to focus an input programmatically. When you pass a ref to a `ref` attribute in JSX, like `<div ref={myRef}>`, React will put the corresponding DOM element into `myRef.current`. You can read more about this in [Manipulating the DOM with Refs.](/learn/manipulating-the-dom-with-refs)
|
||||
You can point a ref to any value. However, the most common use case for a ref is to access a DOM element. For example, this is handy if you want to focus an input programmatically. When you pass a ref to a `ref` attribute in JSX, like `<div ref={myRef}>`, React will put the corresponding DOM element into `myRef.current`. Once the element is removed from the DOM, React will update `myRef.current` to be `null`. You can read more about this in [Manipulating the DOM with Refs.](/learn/manipulating-the-dom-with-refs)
|
||||
|
||||
<Recap>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user