javascript - Access Child Element's DOM Node in React -
i working react & svg.
in order centre viewbox on child <g>, need 'bbox' value calling getbbox() api function on child <g> element. code looks this:
// <svg> element const svgparent = react.createclass({     componentdidmount : function(){     let elebbox = reactdom.finddomnode( this.refs.gele ).getbbox(); ...  // child <g> element const templateparent = react.createclass({    render : function(){       return(          <g ref = "gele"> ... the above line let elebbox = reactdom.finddomnode( this.refs.gele ) returns error: typeerror: _reactdom2.default.finddomnode(...) null
and indeed, this.refs inside 'svg' element empty obj. how access child <g> element, can access dom node?
thanks,
if put ref on child can in parent so, no need dom node:
const svgparent = react.createclass({     componentdidmount : function(){     let elebbox = this.refs.gele     ... 
Comments
Post a Comment