Hi Friends 👋,
Welcome To Infinitbility! ❤️
To convert String to int in react native, just use the Number()
method to convert string to a number.
Like the following example, we can convert string variable data to numbers (integer).
1const x = "134.34";2console.log(Number(x));3// Output4// 134.34
Today, I’m going to show you How do i convert string to int react native, as above mentioned here, I’m going to use the Number()
method to convert string data to number.
Let’s start today’s tutorial how do you convert string to int react native?
In this example, we will do
- Create a sample string variable.
- Use
Number()
method - Print the Output on the screen
1import React, { useState, useEffect } from 'react';2import { Text, View, StyleSheet } from 'react-native';34export default function App() {5 const [num, setNum] = useState(0);67 useEffect(() => {8 let StrNum = "24.234";9 const result = Number(StrNum);10 console.log(result);11 setNum(result);12 }, []);1314 return (15 <View style={styles.container}>16 <Text>{num} - {typeof num}</Text>17 </View>18 );19}2021const styles = StyleSheet.create({22 container: {23 flex: 1,24 justifyContent: 'center',25 backgroundColor: '#ecf0f1',26 padding: 8,27 },28 paragraph: {29 margin: 24,30 fontSize: 18,31 fontWeight: 'bold',32 textAlign: 'center',33 },34});
As above mentioned, we are taken the example of a string variable, converted it into a number, and printed in the screen.
Let’s check the output.

I hope it’s help you, All the best 👍.
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.