Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

React and Refs

I am confused by refs in react, in video with Guil, he says that with a controlled component such a form with a text input that the render method is called on every key stroke and the change in state is reflected in the component. This means that when you type in a text input the change of state is reflected and displayed by re rending the form component.

He says that with refs the render method is called only once, but how are the key strokes reflected in the form as you type if the render method is not called on each key stroke.

I thought that refs are used as a convenient way to access a DOM element and get its value and pass it for example to a submit event callback function. I don't understand how the UI updates via refs no functions are called to update the UI.