Skip to content

phuocng/master-of-react-ref

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Master of React ref

React Ref is a fantastic feature in React that allows you to directly access and manipulate DOM (Document Object Model) elements. In simpler terms, it's a way to reference a specific element in your React app, giving you the power to modify and interact with it outside of the normal React data flow.

This series is your ultimate guide to mastering the use of ref in React. We'll start with the basics, such as string and callback ref, and then dive into more advanced topics like the useRef() hook and forwardRef() API. By the end, you'll have a deep understanding of how to use ref like a pro in your React applications. Get ready to take your React skills to the next level!

Access a component's underlying DOM node with findDOMNode()

String refs

Store a reference with callback refs

Access the methods of class components

Use callback refs to access individual elements in a list

Implement a basic container query with callback refs

Save the element passed to a callback ref as a state

Create a custom hook returning a callback ref

Make an element draggable

Pass refs to child components using the function as a child pattern

Create a reference using React.createRef()

Reference an element with React's useRef() hook

Build your own drawing board

Drag and drop items within a list

Persist values between renders

Save the previous value of a variable

Detect whether an element is in view

Pass a ref to a custom hook

Merge different refs

Build a tooltip component

Pass a ref to a child component using forwardRef()

Expose methods of a component using useImperativeHandle()

About

Your complete guide to mastering the use of "ref" in React

Topics

Resources

License

Stars

Watchers

Forks