查看测试用例/预期的错误,您是正确的,应该克隆对象。
Warning: `div` was passed a style object that has previously beenmutated. Mutating `style` is deprecated. Consider cloning itbeforehand. Check the `render` of `App`. Previous style:{border: "1px solid black"}. Mutated style:{border: "1px solid black", position: "absolute"}.https://github.com/facebook/react/blob/fc96f31fade8043856eb7bc34c56598c4a576110/src/renderers/dom/shared/
测试 /ReactDOMComponent-
test.js#L128
我想这与道具的推理类似-它使您免于在任何地方传递可变样式对象,并最终失去了React真正擅长为您提供帮助的大量推理功能。
The props object is now frozen, so mutating props after creating a componentelement is no longer supported. In most cases, React.cloneElement should beused instead. This change makes your components easier to reason about andenables the compiler optimizations mentioned above.



