MCPcopy
hub / github.com/facebook/react / findDOMNode

Function findDOMNode

packages/react-dom/src/client/ReactDOMRootFB.js:356–386  ·  view source on GitHub ↗
(
  componentOrElement: Element | ?component(...props: any),
)

Source from the content-addressed store, hash-verified

354}
355
356export 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
388export function render(
389 element: React$Element<any>,

Callers 15

componentDidMountFunction · 0.90
componentDidMountMethod · 0.50
componentDidUpdateMethod · 0.50
componentDidMountMethod · 0.50
componentWillUnmountMethod · 0.50
componentDidMountMethod · 0.50
componentWillUnmountMethod · 0.50
componentDidUpdateMethod · 0.50
componentDidMountMethod · 0.50
AppFunction · 0.50

Calls 4

findHostInstanceFunction · 0.90
getComponentNameFromTypeFunction · 0.85
errorMethod · 0.65

Tested by 12

componentDidMountMethod · 0.40
componentDidUpdateMethod · 0.40
componentDidMountMethod · 0.40
componentWillUnmountMethod · 0.40
componentDidMountMethod · 0.40
componentWillUnmountMethod · 0.40
componentDidUpdateMethod · 0.40
componentDidMountMethod · 0.40
AppFunction · 0.40
componentDidUpdateMethod · 0.40
componentDidMountMethod · 0.40
componentDidUpdateMethod · 0.40