打字稿中的历史记录是什么类型?

时间:2020-11-06 04:46:01

标签: reactjs typescript

我现在将routecomponentprops的历史记录传递给辅助函数。

这是主要组成部分

const FinishEmailSignup: React.FunctionComponent<RouteComponentProps> = ({ history }) => {

  useEffect(( ) => {
    testEmailAuth(history);
 }, [history])

现在这是我放置所有辅助函数的另一个组件。我现在将any的类型设为historytype道具正确的history是什么

export function testEmailAuth ( history: any ) {
    if (firebase.auth().isSignInWithEmailLink(window.location.href)) {
          //Do Something
        });
    }
}

1 个答案:

答案 0 :(得分:3)

您可以从“ history”包中获取类型,react-router取决于该包:

import { History } from 'history';

export function testEmailAuth(history: History) {

或者,您也可以这样:

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

export function testEmailAuth(history: RouteComponentProps['history']) {