Course contentsShow
← React
Lesson 1221 of 2,39631. Forms in ReactFree lesson

watch() for Reactive Values

Using watch() to subscribe to specific fields when you need their values in render without full re-renders.

watch() for Reactive Values

You'll learn: How to access form field values in your component's render logic without causing expensive re-renders on every keystroke.

The Challenge

With React Hook Form, fields are uncontrolled by default—their values live in the DOM, not React state. But what if you need a field's current value during render? Maybe to show a character count, toggle UI based on selections, or compute a derived value?

How watch() Works

The watch() function from useForm lets you subscribe to specific field values. It returns the current value and triggers a re-render only when that field changes—not the entire form:

const { register, watch } = useForm();

const password = watch('password');
const confirmPassword = watch('confirmPassword');

// Now you can use these values in render:
const passwordsMatch = password === confirmPassword;

You can also watch multiple fields at once:

const [firstName, lastName] = watch(['firstName', 'lastName']);
const fullName = `${firstName || ''} ${lastName || ''}`.trim();

Or watch everything (use sparingly):

const allValues = watch(); // Re-renders on any field change

The Smart Part

Unlike controlled inputs that re-render on every keystroke for all fields, watch() creates surgical subscriptions. Your component only re-renders when the watched fields change—other fields typing away won't trigger updates.

Key Takeaway: Use watch() when you need field values during render (conditional UI, computed values, live previews) without the performance cost of fully controlled forms. It's the best of both worlds—uncontrolled performance with reactive access when needed.