ionic-framework - 找不到名称 'RouteComponentProps' 。 TS2304

标签 ionic-framework ionic-react

我只是尝试按照说明从 ionic x react 文档中构建一个待办事项应用程序,
但是当我尝试要求时出现此错误(查看图片)
*Capture of result on the page*
这是我的代码,有人看到我做错了什么吗?

import { IonContent,
     IonHeader,
     IonPage,
     IonTitle,
     IonToolbar,
     IonList,
     IonItem,
     IonCheckbox,
     IonNote,
     IonLabel,
     IonBadge,
     IonFab,
     IonFabButton,
     IonIcon} from '@ionic/react';
import React from 'react';
import { add } from 'ionicons/icons';

const Home: React.FC<RouteComponentProps> = (props) => {
  return (
    <IonPage>
      <IonHeader>
        <IonToolbar>
          <IonTitle>Awema</IonTitle>
        </IonToolbar>
      </IonHeader>
      <IonContent className="ion-padding">
        <IonList>
          <IonItem>
            <IonCheckbox slot="start" />
            <IonLabel>
              <h1>Create Idea</h1>
              <IonNote>Run Idea by Brandy</IonNote>
            </IonLabel>
            <IonBadge color="success" slot="end">
              5 Days
            </IonBadge>
          </IonItem>
        </IonList>
        <IonFab vertical="bottom" horizontal="end" slot="fixed">
          <IonFabButton onClick={() => props.history.push('/new')}>
            <IonIcon icon={add} />
          </IonFabButton>
        </IonFab>
      </IonContent>
    </IonPage>
  );
};

export default Home;

最佳答案

您的应用程序找不到 RouteComponentProps。您可以将它们导入您的应用程序:

import { RouteComponentProps } from "react-router-dom";

关于ionic-framework - 找不到名称 'RouteComponentProps' 。 TS2304,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60019698/

相关文章:

html - 上传的 mp4 视频无法播放 HTML5 Player

node.js - ionic 服务未处理的错误事件

reactjs - 如何动态定位 IonPopover 以从按钮出现?

reactjs - 范围错误: Invalid string length with jest and @testing-library/react

reactjs - react ionic 5 : How to pass object from App component to Tab component

android - 如何在 Android 上实现 ionic io 推送通知

javascript - ionic 不从变量返回数据

html - 对齐无序列表中的元素

reactjs - Ionic/React/TypeScript,使用react-router history.push, history.replace and history.goBack动画触发两次