Friday, 15 April 2011

javascript - Change elements height React Angular -


I am working with angular and react (with ng-feedback) and I I am trying to change the height of another element. I have feedback component with both of these elements, something like this:

  render: function () {returns (& lt; div & Gt; & lt; div className = "absolute" ref = "absoluteCell" & gt; foo & lt; / div & gt; & lt; th ref = "empty cell" style = {this.state.style} & gt;    

To set the height of the targets would like to set up a complete cell. I have tried with componentDidMount in this way:

getInitialState: function {return} {style: {height: '30px'}}}, componentDidMount: Function () {Var absoluteCellHeight = this.refs.absoluteCell.getDOMNode (). OffsetHeight; This.setState ({Genre: {height: absoluteCellHyight}}); This.refs.emptyCell.forceUpdate (); }

But I'm getting a dirty error can not read 'getDOMNode' of the undefined property .

Update: I have changed some code (updated above) and now error '<'> can not read property 'GetDOMNode' is undefined gone But now I am getting an error TypeError: not mandatory on line function this.refs.emptyCell.forceUpdate () .

The height of the empty cell varies correctly and it all works well, but I am still getting that error on the foreupdate () method. Anyone have any ideas? What can I do?

The above code is an anti-pattern anti:

Component in theDidMount Lifecycle , Consider the height correct, though setState () & amp; Amp; Force update () in this life cycle should not be called SetState calculates the difference and recompresses the reaction component ForceUpdate () is a duplicate after setState ()

>

To achieve your goal, please proceed to the argument of changing the style of the empty cell, componentDidUpdate lifecycle, which gives you an opportunity to update the provided domains.


No comments:

Post a Comment