我现在将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']) {