【问题标题】:Is there some way I can fixed this the error that says findDOMNode is deprecated in StrictMode everytime i click the mui datatable?有什么方法可以解决这个错误,每次单击 mui 数据表时,在 StrictMode 中不推荐使用 findDOMNode 的错误?
【发布时间】:2021-06-12 08:08:53
【问题描述】:

这就是每次我单击 muidatatable 时错误所说的内容。有什么办法可以解决这个问题吗?如果不修复,会不会在我以后部署项目的时候出现一些问题?

index.js:1 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 here:

这是我的代码:

import React, {Component} from 'react';
import MUIDataTable from "mui-datatables";
import {firestore} from './../../../firebase/firebase.utils';

class UserTable extends Component {
    constructor() {
        super();
        this.state = { users: []};
      }

    columns = ["Display Name", "Email", "Address"];
    options = {
        filter: true,
        selectableRows: 'none',
      };
  

    componentDidMount() {
        firestore.collection('users')
            .get()
            .then( snapshot => {
                const users = []
                 snapshot.forEach(doc => {
                    const data = doc.data()
                    users.push({"Display Name":data.displayName, 'Email': data.email, 'Address' : data.address});
                })
                this.setState({ users : users})
                // console.log(snapshot)
            })
        .catch(error => console.log(error))
    }   

    render() {
        return this.state.users ? (
            <MUIDataTable
              title={"List of Users"}
              columns={this.columns}
              data={this.state.users}
              options={this.options}
            />
          ) : (
            <div>Loading...</div>
          );
        }
      }
 
export default UserTable;

【问题讨论】:

    标签: reactjs material-ui mui-datatable


    【解决方案1】:

    要修复此错误,您必须将 @material-ui/core 更新到 v5 或删除 StrictMode。 Github issue

    【讨论】:

    • 每当我点击 mui-datatable 时,我仍然会遇到同样的错误
    猜你喜欢
    • 1970-01-01
    • 2020-09-08
    • 2021-04-08
    • 2021-10-12
    • 2020-12-19
    • 2020-07-07
    • 2019-05-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多