5 ms·
Not technically, but they sure don't have to make it easy. Getting an element reference is clearly not the optimized-for use case. The docs even warn against
by recursive 2y ago
Not technically, but they sure don't have to make it easy. Getting an element reference is clearly not the optimized-for use case. The docs even warn against it.
> Refs are an escape hatch. Manually manipulating another component’s DOM nodes can make your code fragile.
https://react.dev/learn/manipulating-the-dom-with-refs https://react.dev/learn/manipulating-the-dom-with-refs
- robertoandred 2y agoUsing HTML features doesn't have to mean manipulating another component's nodes.
- recursive 2y agoBut sometimes it does.
- robertoandred 2y agoAnd that’s different from the primary use case of refs
- recursive 2y agoIndeed, and it's also the most practical way to use standard DOM operations from inside of react.