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;
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.
- I don't know which component I will get as BaseComponent
- 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
add a comment |
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.
- I don't know which component I will get as BaseComponent
- 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
1
Can you make any assumptions on the children? Why do you need the underlying dom node?
– Lorenz Henk
Mar 8 at 9:31
Ifchildrenis 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 theBaseComponentscomponentDidUpdate, 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
add a comment |
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.
- I don't know which component I will get as BaseComponent
- 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
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.
- I don't know which component I will get as BaseComponent
- 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
reactjs react-dom
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
Ifchildrenis 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 theBaseComponentscomponentDidUpdate, 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
add a comment |
1
Can you make any assumptions on the children? Why do you need the underlying dom node?
– Lorenz Henk
Mar 8 at 9:31
Ifchildrenis 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 theBaseComponentscomponentDidUpdate, 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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
childrenis 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
BaseComponentscomponentDidUpdate, 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