简体   繁体   English

检查`Drawer`的渲染方法。 元素类型无效错误

[英]Check the render method of `Drawer`. Element type is invalid Error

I'm using react js and antd.design library in my project . 我在我的项目中使用react js和antd.design库。 i'm trying to use a DRAWER component but i got an error : Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. 我正在尝试使用DRAWER组件,但出现错误:元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件),但得到了:对象。

Check the render method of Drawer . 检查Drawer的渲染方法。

the problem is with the Drawer Component , when i remove it the project runs perfeclty , when i add it the error appear again 问题出在Drawer Component上,当我将其删除时,项目运行正常,当我添加它时,错误再次出现

this is my code : 这是我的代码:

import PropTypes from "prop-types";
import { withStyles } from "@material-ui/core/styles";
import "antd/dist/antd.css";
import React from "react";
import "antd/dist/antd.css";
import { Drawer, Button } from "antd";
import Stepper from "../addExperience/stepper";
import { Icon } from "antd";
import ElementClass from "./DrawerElement"
const IconText = ({ type, text }) => (
  <span>
    <Icon type={type} style={{ marginRight: 8 }} />
    {text}
  </span>
);
 class MyClass extends React.Component {
  state = { visible: false };

  showDrawer = () => {
    this.setState({
      visible: true
    });
  };

  onClose = () => {
    this.setState({
      visible: false
    });
  };

  render() {
    return (
      <div>
        <a style={{ color: "#A6A6A6" }} onClick={this.showDrawer}>
          {" "}
          <IconText type="edit" text="Modifier" />{" "}
        </a>
          <Drawer
          title="Modifier cette experience"
          width={720}
          placement="right"
          onClose={this.onClose}
          maskClosable={false}
          visible={this.state.visible}
          style={{
            height: "calc(100% - 55px)",
            overflow: "auto",
            paddingBottom: 53
          }}
        >
          <Stepper />
          <div
            style={{
              position: "absolute",
              bottom: 0,
              width: "100%",
              borderTop: "1px solid #e8e8e8",
              padding: "10px 16px",
              textAlign: "right",
              left: 0,
              background: "#fff",
              borderRadius: "0 0 4px 4px"
            }}
          >
            <Button
              style={{
                marginRight: 8
              }}
              onClick={this.onClose}
            >
              Cancel
            </Button>
            <Button onClick={this.onClose} type="primary">
              Mettre à jour
            </Button>
          </div>
        </Drawer>  
      </div>
    );
  }
}

MyClass.propTypes = {
  classes: PropTypes.object.isRequired
};

export default withStyles()(MyClass);

I think your issue is that you are wrapping some of the arguments in {} , which makes the supplied value an object, rather than the expected datatype. 我认为您的问题是您将一些参数包装在{} ,这使提供的值成为对象,而不是预期的数据类型。

Check the API documentation , which for example says that width wants a datatype which is string|number meaning a string or a number. 检查API文档 ,例如说width想要一个数据类型,该数据类型为string|number表示字符串或数字。 You have specified {720} which is an object. 您已指定{720}这是一个对象。 Make sure all your arguments use the correct data types. 确保所有参数都使用正确的数据类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:元素类型无效,检查相机的渲染方法 - Error: Element type is invalid with Check the render method of Camera 错误:元素类型无效,检查 React Native 中的渲染方法 - Error: Element type is invalid with Check the render method in React Native 元素类型无效:检查渲染方法 - Element type is invalid: check the render method ReactJs元素类型无效检查render方法 - ReactJs Element type is invalid Check the render method React-Native 错误:元素类型无效 ()。 检查`Details`的渲染方法 - React-Native Error: Element type is invalid(). Check the render method of `Details` 元素类型无效:检查提供者的渲染方法(React Native) - Element type is invalid: Check render method of Providers (React Native) React Native Element Type无效。 选中渲染方法 - React Native Element Type is Invalid. Check Render Method 组件异常:元素类型无效,请检查应用程序的渲染方法 - Component Exception: Element Type is Invalid, check render Method of app 在 React Native App 中,我得到了错误:元素类型无效:期望一个字符串(对于内置组件)...检查 `App` 的渲染方法? - In React Native App, I Got the Error: Element type is invalid: expected a string (for built-in components) ... Check the render method of `App`? 检查 Drawer Item 的渲染方法 - Check the Render Method of Drawer Item
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM