Warnings in strict mode
See original GitHub issueEDIT: For the developers that feel adventurous, they can try:
import {
- createMuiTheme,
+ unstable_createMuiStrictModeTheme as createMuiTheme,
darken,
} from '@material-ui/core/styles';
It’s available since #20523, v4.9.11, our intended version for v5. You can find the documentation at https://material-ui.com/customization/theming/#unstable-createmuistrictmodetheme-options-args-theme.
I am playing with Suspense on my project topheman/react-fiber-experiments. I have the following warnings in development:
Warning: Legacy context API has been detected within a strict-mode tree:
Please update the following components: MuiThemeProvider, WithStyles(AppBar), WithStyles(ButtonBase), WithStyles(Card), WithStyles(CardContent), WithStyles(CssBaseline), WithStyles(Drawer), WithStyles(Footer), WithStyles(Header), WithStyles(HomeContainer), WithStyles(IconButton), WithStyles(MainDrawer), WithStyles(MainLayout), WithStyles(Modal), WithStyles(Paper), WithStyles(SvgIcon), WithStyles(Toolbar), WithStyles(Typography)
Learn more about this warning here:
https://fb.me/react-strict-mode-warnings
Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of ButtonBase which is inside StrictMode. Instead, add a ref directly to the element you want to reference.
in button (created by ButtonBase)
in ButtonBase (created by WithStyles(ButtonBase))
in WithStyles(ButtonBase) (created by IconButton)
in IconButton (created by WithStyles(IconButton))
in WithStyles(IconButton) (at Header.js:76)
in div (created by Toolbar)
in Toolbar (created by WithStyles(Toolbar))
in WithStyles(Toolbar) (at Header.js:75)
in header (created by Paper)
in Paper (created by WithStyles(Paper))
in WithStyles(Paper) (created by AppBar)
in AppBar (created by WithStyles(AppBar))
in WithStyles(AppBar) (at Header.js:74)
Learn more about using refs safely here:
https://fb.me/react-strict-mode-find-node
The Suspense part (asynchronous fetching, placeholders …) works ok out of strict mode - check the demo.
Though, the async render part (time slicing) may need strict mode (check the link bellow). This is something to dig into now, people will soon be trying alphas of Suspense and a new major version of react will come in a few months.
Related: Migrate from findDOMNode to refs
Your Environment
Tech | Version |
---|---|
Material-UI | v3.1.2 |
React | v16.6.0 - custom build from this commit |
Browser | Chrome |
More infos:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:223
- Comments:73 (41 by maintainers)
Top GitHub Comments
This will be solved in v5. We can’t fix it without a breaking change. I’ll put together a gist how to fix this in your app by using the theme.
May be disable
StrictMode
replace
to
https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects