UNPKG

533 BJavaScriptView Raw
1import { findDOMNode } from 'react-dom';
2
3export default function findNode(target, param) {
4 if (!target) {
5 return null;
6 }
7
8 if (typeof target === 'string') {
9 return document.getElementById(target);
10 }
11
12 if (typeof target === 'function') {
13 try {
14 target = target(param);
15 } catch (err) {
16 target = null;
17 }
18 }
19
20 if (!target) {
21 return null;
22 }
23
24 try {
25 return findDOMNode(target);
26 } catch (err) {
27 return target;
28 }
29}
\No newline at end of file