小编jfr*_*484的帖子

带有 Transition 的对话框抛出 JS 警告“在 StrictMode 中不推荐使用 findDOMNode”

我创建了一个简单的 Dialog 组件,它是可拖动的,可以根据此处的示例代码进出(使用 Grow)过渡:https : //material-ui.com/components/dialogs/#transitions(向下滚动可拖动例子)

当我尝试使用此对话框时,它运行良好。但是,控制台每次都会收到几个警告: findDOMNode 堆栈跟踪

这是我的代码:

    const Transition = React.forwardRef(function Transition(props, ref) {
        return <Grow ref={ref} {...props} />;
    });

    export class PaperComponent extends React.Component {
        render() {
            return (
                <Draggable handle="#draggable-dialog-title" cancel={'[class*="MuiDialogContent-root"]'}>
                    <Paper {...this.props} />
                </Draggable>
            );
        }
    }

    export class BasicDialog extends React.Component {
        render() {
            return (
                <Dialog
                    open={this.props.dialogData.title ?? false}
                    PaperComponent={PaperComponent}
                    TransitionComponent={Transition}>
                    <DialogTitle style={{ cursor: 'move' }} id="draggable-dialog-title">
                        {this.props.dialogData.title}
                    </DialogTitle>
                    <DialogContent style={{ textAlign: 'center' }}>
                        <DialogContentText>
                            {this.props.dialogData.text}
                        </DialogContentText>
                        {this.props.dialogData.content}
                    </DialogContent>
                    <DialogActions style={{ justifyContent: …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

5
推荐指数
1
解决办法
1775
查看次数

标签 统计

material-ui ×1

reactjs ×1