A component exposes the innerRef
prop that always returns the DOM node of both functional and class component children.
React.useRef()
Type | nodeName | textContent |
---|---|---|
Functional ref via React.useState() hook | DIV | An example node with functional ref |
From React.useRef() hook | DIV | An example node with ref via React.useRef() |
React.forwardRef()
API is also handled by this component.
A button below uses React.forwardRef()
API.
{ "nodeName": "BUTTON", "nodeType": 1, "textContent": "A button" }