Invalid "Mutating `style` is deprecated." warning in 0.14.0-rc1?
See original GitHub issueI get the following warning in 0.14.0-rc1:
Warning:
div
was passed a style object that has previously been mutated. Mutatingstyle
is deprecated. Consider cloning it beforehand. Check therender
ofPreview
. Previous style: {“color”:“#747474”,“backgroundColor”:“#009988”,“fontSize”:null,“fontWeight”:“300”}. Mutated style: {“color”:“#747474”,“backgroundColor”:“#009988”,“fontSize”:null,“fontWeight”:“300”}.
I’m confused why this warning appears because the “Previous style” and the “Mutated style” look exactly the same.
To reproduce the issue:
$ git clone git@github.com:moroshko/accessible-colors.git
$ cd accessible-colors
$ git checkout 1d8efda7145ff316b78e60cc0f0ebe113da11367
$ npm install
$ npm start
Then open http://localhost:3000/dist/index.html
in a browser, and:
- Type “1” in the font size field
- Blur that field Now you should see the warning in the console.
Why this warning is displayed? How could I fix it?
Issue Analytics
- State:
- Created 8 years ago
- Comments:24 (11 by maintainers)
Top Results From Across the Web
Why was mutating style deprecated? - reactjs - Stack Overflow
You can work around this problem by copying the the previous style into a new variable and copying the previous style object. Example:...
Read more >SciPy 1.8.0 Release Notes — SciPy v1.9.3 Manual
NumericalInverseHermite has been deprecated from scipy.stats and moved to the ... #14140: Likely unnecessary invalid value warning from PchipInterpolator.
Read more >Changelog and Migration Guide - Detekt
We deprecated the MultiRule class as it was overly complicated. The suggested approach is to just provide separated rules.
Read more >Important notes — Borg - Deduplicating Archiver 1.2.3 ...
As they were considered invalid, borg discarded them. ... C / Cython compiler warnings, deprecation warnings; fix zstd.h include for bundled zstd, #6369....
Read more >@material-ui/styles | Yarn - Package Manager
@material-ui/styles. owner mui-org7.1mMITdeprecated4.11.5TS vulns 0 vulnerabilities.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I ran into this issue while using
Object.assign
. I just set the target to be an empty object so there’s a new memory reference.@AoDev the first does not throw a warning because of this line:
That’s creating a new style object with a new memory reference, so you’re actually not passing a mutated object. In the second you’re passing
store.style
which is the same object with the same reference before and after mutation.You can fix the second with:
Be sure to do this with care though because of the performance implications (passing props like this to pure children will always force a render, removing the benefits of pure components).