首页 > 解决方案 > Typescript TS2604:JSX 元素类型“抽屉”没有任何构造或调用签名

问题描述

我已经尝试过在 stackoverflow 中找到的其他解决方案,但是我错了,因为没有人为我工作。

有人可以帮助纠正这个 ts 错误吗?

错误 TS2604:JSX 元素类型“抽屉”没有任何构造或调用签名。

所有测试都失败

带功能

import React, {Component} from "react";
import Drawer from "@material-ui/core";
import { Scrollbars } from 'react-custom-scrollbars';
const DrawerB = () => (

            <Drawer
                open={true}
            >
                <h1>AAAA</h1>
            </Drawer>
        );

与类

        class DrawerA extends Component<any, any>{
            constructor(props){
                super(props)
            }
            render(){
                return (
                    <Drawer
                        open={true}
                    >
                        <h1>AAAA</h1>
                    </Drawer>
                )
            }
        }

有类和无构造

        class DrawerC extends Component<any, any>{

            render(){
                return (
                    <Drawer
                        open={true}
                    >
                        <h1>AAAA</h1>
                    </Drawer>
                )
            }
        }

标签: reactjstypescript

解决方案


如下更改您的导入可能会对您有所帮助:

import { Drawer } from "@material-ui/core";

推荐阅读