in Education by
This is part of the component : import MyComp from '../../lib/MyComp' const Data = ( { data } ) => (
) How do I get the width of the data-box div inside MyComp container? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Check this working demo: JSFiddle: var Parent = React.createClass({ render: function() { return
Hello Parent
; } }); var Child = React.createClass({ componentDidMount: function() { alert('Parent width: ' + this.refs.child.parentNode.clientWidth); }, render: function() { return
Hello Child
; } }); Stating ref="child" will make the element accessable by the component itself, through this.refs.child. It is the vallina node instance. Using this.refs.child.parentNode.clientWidth will return the parent's width. Or, use this.refs.child.parentNode.getBoundingClientRect(). Reference: React refs

Related questions

0 votes
    This is part of the component : import MyComp from '../../lib/MyComp' const Data = ( { data } ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    Course Results (${courseResponseList.getCourses().size()}) Want to show above div. jquery script. jQuery. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    i have a website that contain an iframe. www.vendeposto.com.br and i want to hide an element Im trying to do this ... the vendeposto.com.br site is this: Postos de gasolina a venda...
asked May 1, 2022 in Education by JackTerrance
0 votes
    i have a website that contain an iframe. www.vendeposto.com.br and i want to hide an element Im trying to do this ... the vendeposto.com.br site is this: Postos de gasolina a venda...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    i have a website that contain an iframe. www.vendeposto.com.br and i want to hide an element Im trying to do this ... the vendeposto.com.br site is this: Postos de gasolina a venda...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    Course Results (${courseResponseList.getCourses().size()}) Want to show above div. jquery script. jQuery. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    Basically I've managed to layout my DIV elements into a circle shape but I've not managed to work ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    Basically I've managed to layout my DIV elements into a circle shape but I've not managed to work ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    Basically I've managed to layout my DIV elements into a circle shape but I've not managed to work ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I'm importing Popup from react-leaflet import { Marker, Map, Popup, TileLayer, ZoomControl, GeoJSON, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I have a REACTSjs application and am trying to solve a problem with localization. I receive some text from ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I'm trying to use the sensor's API with react and I can't seen to be able to make it work ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I'm trying to use the sensor's API with react and I can't seen to be able to make it work ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 10, 2022 in Education by JackTerrance
...