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



我现在将routecomponentprops历史传递给助手函数。

这是的主要组成部分

const FinishEmailSignup: React.FunctionComponent<RouteComponentProps> = ({ history }) => {
useEffect(( ) => {
testEmailAuth(history);
}, [history])

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

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

您可以从"history"包中获取类型,react路由器依赖于:

import { History } from 'history';
export function testEmailAuth(history: History) {

或者,你可以这样做:

import { RouteComponentProps } from 'react-router-dom';
export function testEmailAuth(history: RouteComponentProps['history']) {

最新更新