M
M
Mikhail Malanyuk2015-10-22 21:22:37
React
Mikhail Malanyuk, 2015-10-22 21:22:37

How to work with Style in React.js version 0.14?

Good afternoon. The essence of the problem:
With the transition to version 0.14, warning appears:

Warning: `div` was passed a style object that has previously been mutated. Mutating `style` is deprecated. Consider cloning it beforehand.

So I can't figure out what to do. And I looked at the official site, and googled ... I did not see the answer.
Who will tell you how to dynamically change styles ?!
Update:
Sample Code
render(){
   var handler_a_style = {
      cursor: "pointer",
      left: this.state.first_value
    };

    var handler_b_style = {
      cursor: "pointer",
      left: this.state.second_value
    };
   return (
      <div className="rangefield" ref="line">				
        <span className="rangefield__handler left" style={handler_a_style} ref="span_a"></span>
        <span className="rangefield__handler right" style={handler_b_style} ref="span_b"></span>
      </div>
    );

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Antropov, 2015-10-23
@CJay

Most likely swears at this piece

var range_style = {
                        left : start,
                        width : end-start
                };

In case of getting null NaN

N
Nikita Gushchin, 2015-10-22
@iNikNik

You're mutating an object with styles - don't do it like that. If you need to change styles - create a new object and pass it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question