'convert routeParams from string to number
I have a simple project and in this project I am trying to return data through the id number, and I used “routeParams”, but I had a problem that the “routeParams” is of a string type and I want to convert it to a number, how can I do that?
const routeParams = useParams();
useDeepCompareEffect(() => {
dispatch(getReceipt(routeParams.orderId));
}, [dispatch, routeParams.orderId]);
Solution 1:[1]
You can use parseInt it will return parsed number if you have correct value or NaN if not
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Wraithy |
