Using useNavigate in React with Typescript

Viewed 392

I have a page in my React app that sends the userID to the next page like this:

navigate('../Stats', { state: { userID: newID } });

'newID' is always going to be something like '67'.

On the 'Stats' page I'd like to be able to access this variable. Based on the documentation: https://reactnavigation.org/docs/params/ I should be able to do this:

function StatsPage({ route, navigation }) {

...

  const { userID } = route.params;

However I am getting this error on both route and navigation:

Binding element 'route' implicitly has an 'any' type.ts(7031)

and

Binding element 'navigation' implicitly has an 'any' type.ts(7031)

What type am I supposed to give route and navigation?

0 Answers
Related