0% found this document useful (0 votes)
29 views8 pages

49 - Refs

Refs are used to store references to elements in the DOM. They allow direct changes to be made to elements, rather than using props. Refs provide a way to access DOM nodes or React elements to interact with them. They should generally be avoided and overuse is not recommended. Refs are created by using React.createRef() and assigned to elements via the ref attribute, then can be referenced as a property. The node reference is accessed via the current attribute of the ref.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views8 pages

49 - Refs

Refs are used to store references to elements in the DOM. They allow direct changes to be made to elements, rather than using props. Refs provide a way to access DOM nodes or React elements to interact with them. They should generally be avoided and overuse is not recommended. Refs are created by using React.createRef() and assigned to elements via the ref attribute, then can be referenced as a property. The node reference is accessed via the current attribute of the ref.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

PART-49

React Refs
REACT
PRESENTER: MOHAMMAD ADIL
Humble Request REACT

Techno Verse YT

Heavenly Delicious
React Refs REACT

• Refs are used to store the reference of an element.


• By using Refs we can make changes to the element directly in the
actual DOM.
React Refs REACT

<h1> <input>
Attach
<img>
Ref Element
Properties Get

Make Changes In DOM Directly


React Refs REACT

• Refs is the shorthand used for references in React.


• It is similar to keys in React.
• It is an attribute which makes it possible to store a reference to
particular DOM nodes or React elements.
• It provides a way to access React DOM nodes or React elements and
how to interact with it.
• It is used when we want to change the value of a child component,
without making the use of props.
React Refs REACT

• Note: You should have to avoid overuse of the Refs.


How to create Refs REACT

• In React, Refs can be created by using React.createRef().


• It can be assigned to React elements via the ref attribute.
• It is commonly assigned to an instance property when a component is
created, and then can be referenced throughout the component.
How to access Refs REACT

• In React, when a ref is passed to an element inside render method, a


reference to the node can be accessed via the current attribute of the
ref.

You might also like