score:3

Accepted answer

this warning is coming because left or top being nan. initialize your left or top to zero or some value in getinitialstate function.

  getinitialstate: function() {
    return {
      left:0,
      top: 0
    };

also cloning react-element won't help you here. warning is saying you have to clone your style object when you are making changes to it. which can be done as

var style1 = {myprop: "value"};
var style2 = object.assign({}, style1, {newprop:"newvalue"}); 

instead of setting them directly as

<componentone style={{left: this.state.left, top: this.state.top}} /> 

do in this way

var mystyle = {left: this.state.left, top: this.state.top};
<componentone style={mystyle} /> 

and then based on your changes clone your mystyle object and add changed style properties to it.


Related Query

More Query from same tag