Hi Friends 👋,
Welcome To Infinitbility! ❤️
To use string from function in react native, just use the like ${function()}/hello
syntax to call a function and concat in a string.
Like the following example, we can create a function that return a string and uses a function in a react native render function.
1const getLink= () => {2 const url = 'https://infinitbility.com/'3 return url;4}567const link = `${getLink()}about`; // https://infinitbility.com/about
Today, I’m going to show you How do i return and use a string from a function in react native, as above mentioned here, I’m going to use some basic syntax of ECMAScript.
Let’s start today’s tutorial how do you return and use a string from a function in react native?
In this example, we will do
- Create samples return string function.
- Use the function with tiny ( ` ) in react native render.
- Print the Output on the screen
1import React, { useState, useEffect } from 'react';2import { Text, View, StyleSheet } from 'react-native';34export default function App() {56 const getLink= () => {7 const url = 'https://infinitbility.com/'8 return url;9 }1011 return (12 <View style={styles.container}>13 <Text>{`${getLink()}about`}</Text>14 </View>15 );16}1718const styles = StyleSheet.create({19 container: {20 flex: 1,21 justifyContent: 'center',22 backgroundColor: '#ecf0f1',23 padding: 8,24 },25 paragraph: {26 margin: 24,27 fontSize: 18,28 fontWeight: 'bold',29 textAlign: 'center',30 },31});
As mentioned above, we are taken the example of a return string function, use string function in react native render, concat with string, and printed on 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.