UseRef is a react hook that is basically used to store the reference of something like let's say a DOM element. It takes a single argument as initial value and returns an object with a single property called current. We'll be building a simple modal, as shown below and when a user clicks outside it, we'll close it.

9m read timeFrom nikhilbelide.hashnode.dev
Post cover image
Table of contents
What Is useRef?useRef in Action.1. Close Modal when clicked outside it.2. Move to next input element on Enter3. What is forwardRef?SummaryReferences
1 Impression2 Comments