how to get underlying dom node in react The 2019 Stack Overflow Developer Survey Results Are InLoop inside React JSXReact 0.13 this.getDOMNode() equivalent to React.findDOMNode()Programmatically navigate using react routerReact renderToString() Performance and Caching React ComponentsHow to get ref in DOM node's children in React?Can't get ref of underlying button?Should I use ref or findDOMNode to get react root dom node of an element?How to find and modify DOM nodes in the React before render?How to find the DOM element of a functional children in React?How to get a ref to the dom node of a google map's marker in react?

Which Sci-Fi work first showed weapon of galactic-scale mass destruction?

FPGA - DIY Programming

Is a "Democratic" Oligarchy-Style System Possible?

How technical should a Scrum Master be to effectively remove impediments?

Delete all lines which don't have n characters before delimiter

The difference between dialogue marks

Does a dangling wire really electrocute me if I'm standing in water?

Why did Acorn's A3000 have red function keys?

Did 3000BC Egyptians use meteoric iron weapons?

Why isn't airport relocation done gradually?

What is the closest word meaning "respect for time / mindful"

Is flight data recorder erased after every flight?

Time travel alters history but people keep saying nothing's changed

What does ひと匙 mean in this manga and has it been used colloquially?

One word riddle: Vowel in the middle

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

Scaling a graph of a circle and the standard parabola in TikZ

Are there incongruent pythagorean triangles with the same perimeter and same area?

Why do UK politicians seemingly ignore opinion polls on Brexit?

Where to refill my bottle in India?

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Does the shape of a die affect the probability of a number being rolled?

Do these rules for Critical Successes and Critical Failures seem Fair?

Why was M87 targetted for the Event Horizon Telescope instead of Sagittarius A*?



how to get underlying dom node in react



The 2019 Stack Overflow Developer Survey Results Are InLoop inside React JSXReact 0.13 this.getDOMNode() equivalent to React.findDOMNode()Programmatically navigate using react routerReact renderToString() Performance and Caching React ComponentsHow to get ref in DOM node's children in React?Can't get ref of underlying button?Should I use ref or findDOMNode to get react root dom node of an element?How to find and modify DOM nodes in the React before render?How to find the DOM element of a functional children in React?How to get a ref to the dom node of a google map's marker in react?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am writing an high order component. The render() function only renders the children:



function myHOC(BaseComponent) 
return class HOC extends Component
...
componentDidUpdate()
// get somehow the children's node

...
render()
return children;





I need the rendered dom node.



  1. I don't know which component I will get as BaseComponent

  2. I can't assume anything about BaseComponent implementation.

Therefore I don't know how I can use refs under those conditions.
Now that findDOMNode is deprecated - what else can I do in order to get the underlying dom node?










share|improve this question

















  • 1





    Can you make any assumptions on the children? Why do you need the underlying dom node?

    – Lorenz Henk
    Mar 8 at 9:31











  • If children is arbitrary element, you can't. The rendering of React component can result in multiple DOM nodes, or no nodes at all. Consider explaining your case, this could be XY problem.

    – estus
    Mar 8 at 9:47











  • I am trying to write HOC that debug why a component re-rendered. In order to show the result, I want to create an overlay over the component. For that I need to attach that overlay to some dom node and position it correctly. @LorenzHenk I can't assume a thing since this is a common use.

    – Naor
    Mar 8 at 10:10












  • So what you actually want to do is hook into the BaseComponents componentDidUpdate, right?

    – Lorenz Henk
    Mar 8 at 10:16












  • Right, and add a div with info on top of it.

    – Naor
    Mar 8 at 13:29

















0















I am writing an high order component. The render() function only renders the children:



function myHOC(BaseComponent) 
return class HOC extends Component
...
componentDidUpdate()
// get somehow the children's node

...
render()
return children;





I need the rendered dom node.



  1. I don't know which component I will get as BaseComponent

  2. I can't assume anything about BaseComponent implementation.

Therefore I don't know how I can use refs under those conditions.
Now that findDOMNode is deprecated - what else can I do in order to get the underlying dom node?










share|improve this question

















  • 1





    Can you make any assumptions on the children? Why do you need the underlying dom node?

    – Lorenz Henk
    Mar 8 at 9:31











  • If children is arbitrary element, you can't. The rendering of React component can result in multiple DOM nodes, or no nodes at all. Consider explaining your case, this could be XY problem.

    – estus
    Mar 8 at 9:47











  • I am trying to write HOC that debug why a component re-rendered. In order to show the result, I want to create an overlay over the component. For that I need to attach that overlay to some dom node and position it correctly. @LorenzHenk I can't assume a thing since this is a common use.

    – Naor
    Mar 8 at 10:10












  • So what you actually want to do is hook into the BaseComponents componentDidUpdate, right?

    – Lorenz Henk
    Mar 8 at 10:16












  • Right, and add a div with info on top of it.

    – Naor
    Mar 8 at 13:29













0












0








0








I am writing an high order component. The render() function only renders the children:



function myHOC(BaseComponent) 
return class HOC extends Component
...
componentDidUpdate()
// get somehow the children's node

...
render()
return children;





I need the rendered dom node.



  1. I don't know which component I will get as BaseComponent

  2. I can't assume anything about BaseComponent implementation.

Therefore I don't know how I can use refs under those conditions.
Now that findDOMNode is deprecated - what else can I do in order to get the underlying dom node?










share|improve this question














I am writing an high order component. The render() function only renders the children:



function myHOC(BaseComponent) 
return class HOC extends Component
...
componentDidUpdate()
// get somehow the children's node

...
render()
return children;





I need the rendered dom node.



  1. I don't know which component I will get as BaseComponent

  2. I can't assume anything about BaseComponent implementation.

Therefore I don't know how I can use refs under those conditions.
Now that findDOMNode is deprecated - what else can I do in order to get the underlying dom node?







reactjs react-dom






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 9:22









NaorNaor

10.2k36120225




10.2k36120225







  • 1





    Can you make any assumptions on the children? Why do you need the underlying dom node?

    – Lorenz Henk
    Mar 8 at 9:31











  • If children is arbitrary element, you can't. The rendering of React component can result in multiple DOM nodes, or no nodes at all. Consider explaining your case, this could be XY problem.

    – estus
    Mar 8 at 9:47











  • I am trying to write HOC that debug why a component re-rendered. In order to show the result, I want to create an overlay over the component. For that I need to attach that overlay to some dom node and position it correctly. @LorenzHenk I can't assume a thing since this is a common use.

    – Naor
    Mar 8 at 10:10












  • So what you actually want to do is hook into the BaseComponents componentDidUpdate, right?

    – Lorenz Henk
    Mar 8 at 10:16












  • Right, and add a div with info on top of it.

    – Naor
    Mar 8 at 13:29












  • 1





    Can you make any assumptions on the children? Why do you need the underlying dom node?

    – Lorenz Henk
    Mar 8 at 9:31











  • If children is arbitrary element, you can't. The rendering of React component can result in multiple DOM nodes, or no nodes at all. Consider explaining your case, this could be XY problem.

    – estus
    Mar 8 at 9:47











  • I am trying to write HOC that debug why a component re-rendered. In order to show the result, I want to create an overlay over the component. For that I need to attach that overlay to some dom node and position it correctly. @LorenzHenk I can't assume a thing since this is a common use.

    – Naor
    Mar 8 at 10:10












  • So what you actually want to do is hook into the BaseComponents componentDidUpdate, right?

    – Lorenz Henk
    Mar 8 at 10:16












  • Right, and add a div with info on top of it.

    – Naor
    Mar 8 at 13:29







1




1





Can you make any assumptions on the children? Why do you need the underlying dom node?

– Lorenz Henk
Mar 8 at 9:31





Can you make any assumptions on the children? Why do you need the underlying dom node?

– Lorenz Henk
Mar 8 at 9:31













If children is arbitrary element, you can't. The rendering of React component can result in multiple DOM nodes, or no nodes at all. Consider explaining your case, this could be XY problem.

– estus
Mar 8 at 9:47





If children is arbitrary element, you can't. The rendering of React component can result in multiple DOM nodes, or no nodes at all. Consider explaining your case, this could be XY problem.

– estus
Mar 8 at 9:47













I am trying to write HOC that debug why a component re-rendered. In order to show the result, I want to create an overlay over the component. For that I need to attach that overlay to some dom node and position it correctly. @LorenzHenk I can't assume a thing since this is a common use.

– Naor
Mar 8 at 10:10






I am trying to write HOC that debug why a component re-rendered. In order to show the result, I want to create an overlay over the component. For that I need to attach that overlay to some dom node and position it correctly. @LorenzHenk I can't assume a thing since this is a common use.

– Naor
Mar 8 at 10:10














So what you actually want to do is hook into the BaseComponents componentDidUpdate, right?

– Lorenz Henk
Mar 8 at 10:16






So what you actually want to do is hook into the BaseComponents componentDidUpdate, right?

– Lorenz Henk
Mar 8 at 10:16














Right, and add a div with info on top of it.

– Naor
Mar 8 at 13:29





Right, and add a div with info on top of it.

– Naor
Mar 8 at 13:29












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55060139%2fhow-to-get-underlying-dom-node-in-react%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55060139%2fhow-to-get-underlying-dom-node-in-react%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович