Skip to content

Commit

Permalink
chore: Update findDOMNode define
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Sep 30, 2019
1 parent e34eb0b commit 30f034f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Dom/findDOMNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import ReactDOM from 'react-dom';
/**
* Return if a node is a DOM node. Else will return by `findDOMNode`
*/
export default function findDOMNode(node: React.ReactInstance | HTMLElement): Element | Text {
export default function findDOMNode<T = Element | Text>(
node: React.ReactInstance | HTMLElement,
): T {
if (node instanceof HTMLElement) {
return node;
return (node as unknown) as T;
}
return ReactDOM.findDOMNode(node);
return (ReactDOM.findDOMNode(node) as unknown) as T;
}

0 comments on commit 30f034f

Please sign in to comment.