How to Check a Number is NaN or not in React Native
NaN value stands for not a number value. A value of a number data type becomes NaN when the value is not a number legally. Getting a NaN value instead of a number can even break your react native mobile application.
So, how to check if a number is NaN or not in React Native?
You can use Javascript global function isNaN() to identify whether a value is NaN or not in react native. If the function returns true then it means the number is not-a-number. Hence you can use the function in react native as below:
if(isNaN(yourValue))
{
console.log("yourValue is nan");
}
else
{
console.log("yourValue is a valid number");
}
That’s how you check whether a number is valid or not in react native.