How to use react-router useHistory hook with TypeScript
In my func component I am trying to use history.push in this way: import React, { useEffect } from 'react'; import { useHistory } from 'react-router-dom'; interface Props { question: Question; selectedAnswer: SelectedOption | undefined; } const LastScreen: React.FC<Props> = (props: Props) => { const history = useHistory(); ... useEffect(() => { if (progress === 100) { const id = uuid(); history.push({ pathname: `/p/${id}`, state: { userAnswers }, }); } }, [progress, userAnswers, history]); ... }; but it gives an error: Argument of type '{ pathname: string; state: { userAnswers: UserAnswers | u
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.