How to Convert String to Number in React Native?

Sep 15, 2022 . Admin

Now, let's see post of convert string to number integer in react native javascript. I would like to share with you how to convert string to number in react native. I would like to show you string to number in react native code example. let’s discuss about convert string to array in react native. So, let's follow few step to create example of how to convert integer variable to string in react native.

In this example,We will convert string to number in react can easy and simply use Number() function check to string to number or not.let's below example.

Step 1: Download Project

In the first step run the following command to create a project.

expo init ExampleApp
Step 2: App.js

In this step, You will open the App.js file and put the code.

import React from 'react';
import { StyleSheet, Button, SafeAreaView, Text } from 'react-native';

export default function App() {

    const string1 = "24.25" ;
    const number1 = Number(string1);

    const string2 = "" ;
    const number2 = Number(string2);

    const string3 = " " ;
    const number3 = Number(string3);

    const string4 = "24 26 565" ;
    const number4 = Number(string4);

  return (
    <SafeAreaView style={styleSheet.MainContainer}>
      <Text style={styleSheet.text}> {number1}</Text>
      <Text style={styleSheet.text}> {number2}</Text>
      <Text style={styleSheet.text}> {number3}</Text>
      <Text style={styleSheet.text}> {number4}</Text>

const styleSheet = StyleSheet.create({
  MainContainer: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center'

  text: {
    fontSize: 30,
Step 3: Run Project

In the last step run your project using the below command.

expo start

You can QR code scan in Expo Go Application on mobile.


It will help you...

#React Native