| 354 | } |
| 355 | |
| 356 | export function findDOMNode( |
| 357 | componentOrElement: Element | ?component(...props: any), |
| 358 | ): null | Element | Text { |
| 359 | if (__DEV__) { |
| 360 | const owner = currentOwner; |
| 361 | if (owner !== null && isRendering && owner.stateNode !== null) { |
| 362 | const warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender; |
| 363 | if (!warnedAboutRefsInRender) { |
| 364 | console.error( |
| 365 | '%s is accessing findDOMNode inside its render(). ' + |
| 366 | 'render() should be a pure function of props and state. It should ' + |
| 367 | 'never access something that requires stale data from the previous ' + |
| 368 | 'render, such as refs. Move this logic to componentDidMount and ' + |
| 369 | 'componentDidUpdate instead.', |
| 370 | getComponentNameFromType(owner.type) || 'A component', |
| 371 | ); |
| 372 | } |
| 373 | owner.stateNode._warnedAboutRefsInRender = true; |
| 374 | } |
| 375 | } |
| 376 | if (componentOrElement == null) { |
| 377 | return null; |
| 378 | } |
| 379 | if ((componentOrElement: any).nodeType === ELEMENT_NODE) { |
| 380 | return (componentOrElement: any); |
| 381 | } |
| 382 | if (__DEV__) { |
| 383 | return findHostInstanceWithWarning(componentOrElement, 'findDOMNode'); |
| 384 | } |
| 385 | return findHostInstance(componentOrElement); |
| 386 | } |
| 387 | |
| 388 | export function render( |
| 389 | element: React$Element<any>, |