ReactJs warning: Mutating `style` is deprecated. Consider cloning it beforehand

前端 未结 2 1251
被撕碎了的回忆
被撕碎了的回忆 2021-01-27 00:58

I am receving the following warning:

inWarning: `div` was passed a style object that has previously been mutated. Mutating `style` is deprecated. Consider clonin         


        
2条回答
  •  太阳男子
    2021-01-27 01:37

    You are not cloning the previewColorHover

      var clone = Object.assign({}, this.styles.previewColorHover);
       this.styles.previewColorHover = clone;
       this.styles.previewColorHover.backgroundColor = this.state.selectedColor.hex
    

提交回复
热议问题