'How to deal with react router url params and type script
In react router, I am going through the tutorial but trying to use typescript and have this code
let params = useParams();
let id:string = params.invoiceId
let invoice = getInvoice(parseInt(id, 10));
The second line has an error
TS2322: Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'
How do I do this properly to lookup and display the invoice? Also, how to reroute to the catch all * if the string is not an integer.
thanks, Dean
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
