React Native Combine Two Strings Into One Using concat() Function

The String function .concat() gives us the functionality to merge two or multiple string into one string. So in this tutorial we would going to create a react native Android iOS app with Two different strings and we would Combine Two Strings into one string using the .concat() String function and show the merged text into Text component.

Contents in this project Combine Two Strings Into One Using concat() Function :

1. Import StyleSheet, Text, View and Button component in your project.

2. Create constructor() in your main class and define a state named as SampleText. This state is used to show merged text inside Text component.

3. Create a function named as CombineTwoStrings() . Inside this function we would create 2 String variable named as String_1 and String_2. Now we would Save the String_1 and String_2 var value into String_3 var using concat() function. Finally we would store the String_3 value into SampleText state.

4. Create Parent View in render’s return block with One Text component and One Button. We would call the CombineTwoStrings() function on Button onPress event.

5. Create Style for View and Text component.

6. Complete source code for App.js File :

Screenshot in Android device :

Combine Two Strings

Screenshot in iOS device :