React - Refs
Refs provide a way to access DOM nodes or React elements created in the render method.
They can be used to manage focus, trigger imperative behaviours like animations or integrate with third party code.
The main usecase of refs is to have a refference to the true DOM element that is rendered in the browser. It can be used f.e. to measure size of the element or to focus it.
Access rendered DOM
I can create a refference to the rendered DOM element to manipulate it. I can achieve this using useRef hook for the functional component for React.createRef for class components
Ref forwarding
I can forward ref to the custom component using React.forwardRef HOC wrapper. I understand that ref is a reserved keyword for the props and is passed as second argument of functional component.
I know that I can pass refs using props as an alternative method for special usecases
Combining refs
I know that sometimes you need an access to the ref that is forwarded. I know I can combine different kind of refs using custom combineRef hook
I can create a refference to the rendered DOM element to manipulate it. I can achieve this using useRef hook for the functional component for React.createRef for class components
I can forward ref to the custom component using React.forwardRef HOC wrapper. I understand that ref is a reserved keyword for the props and is passed as second argument of functional component.
I know that I can pass refs using props as an alternative method for special usecases
I know that sometimes you need an access to the ref that is forwarded. I know I can combine different kind of refs using custom combineRef hook