material-ui抽屉-在StrictMode中不建议使用findDOMNode [英] material-ui Drawer - findDOMNode is deprecated in StrictMode

查看:172
本文介绍了material-ui抽屉-在StrictMode中不建议使用findDOMNode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的ReactJS应用程序,该应用程序使用StrictMode基于钩子(没有类).

I have a simple ReactJS app based on hooks (no classes) using StrictMode.

我正在使用React版本16.13.1和Material-UI版本4.9.10.

I am using React version 16.13.1 and Material-UI version 4.9.10.

在Appbar中,我正在使用Drawer.

In the Appbar I am using Drawer.

    <div className={classes.root}>
        <AppBar position="static">
            <Toolbar>
                <IconButton
                    edge="start"
                    className={classes.menuButton}
                    color="inherit"
                    aria-label="menu"
                    onClick={handleDrawerOpen}>
                    <MenuIcon />
                </IconButton>
                <Typography variant="h6" className={classes.title}>
                    Online Information
                </Typography>
            </Toolbar>
        </AppBar>
        <Drawer
            variant="persistent"
            anchor="left"
            open={open}
        ></Drawer>
    </div>

我注意到打开抽屉时,出现以下警告.

I notice that when I open the Drawer, I get the following warning.

Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance 
of 
Transition which is inside StrictMode. Instead, add a ref directly to the element you 
want to reference. Learn more about using refs safely ....
in div (created by Transition)
in Transition (created by ForwardRef(Fade))
in ForwardRef(Fade) (created by ForwardRef(Backdrop))
in ForwardRef(Backdrop) (created by WithStyles(ForwardRef(Backdrop)))
in WithStyles(ForwardRef(Backdrop)) (created by ForwardRef(Modal))
in div (created by ForwardRef(Modal))
in ForwardRef(Portal) (created by ForwardRef(Modal))
in ForwardRef(Modal) (created by ForwardRef(Drawer))
in ForwardRef(Drawer) (created by WithStyles(ForwardRef(Drawer)))

我在网上找到了一些有关此问题的参考,但仍然不知道如何解决此问题.

I found some reference on the web for this issue but still can’t figure out how to resolve this issue.

有人可以为这个问题添加一些解决方法吗?

Can someone please add some workaround for this problem?

谢谢

推荐答案

是的,这很烦人.Material UI的团队跟不上React开发人员.目前,只需删除严格模式"标签即可.不幸的是,尖端技术会发生什么.

Yeah it's annoying. Material UI's team is not keeping up with the React devs. For now, just remove the Strict mode tag. It's unfortunately what happens with cutting edge technologies.

这篇关于material-ui抽屉-在StrictMode中不建议使用findDOMNode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆