Navigate back to the homepage

how to concat string in react native?

Infinitbility
React Native
June 19th, 2022 · 1 min read

Hi Friends 👋,

Welcome To Infinitbility! ❤️

To concat string in react native, just use the + plus operator it will concatenate two strings and show on the screen.

Today, I’m going to show you how do i append strings in another string in react native, as above mentioned we will use + plus operator to concatenate strings.

Let’s start today’s topic how to concat string in react native?

Here we will see an example of showing two state strings in a single text using + plus operator to concat them.

let’s start

1import React, { useState, useEffect } from 'react';
2import { Text, View, StyleSheet } from 'react-native';
3
4export default function App() {
5 const [firstString, setFirstString] = useState('Hi');
6 const [secondString, setSecondString] = useState('Infintbility');
7
8 useEffect(() => {
9 let result = firstString + ' ' + secondString;
10 console.log(result);
11 }, []);
12
13 return (
14 <View style={styles.container}>
15 <Text>{firstString + ' ' + secondString}</Text>
16 </View>
17 );
18}
19
20const styles = StyleSheet.create({
21 container: {
22 flex: 1,
23 justifyContent: 'center',
24 backgroundColor: '#ecf0f1',
25 padding: 8,
26 },
27 paragraph: {
28 margin: 24,
29 fontSize: 18,
30 fontWeight: 'bold',
31 textAlign: 'center',
32 },
33});

Here, we will use ' ' for append space between both words. let’s check the output.

React Native, concat two strings example
React Native, concat two strings example
  • Try it yourself

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.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

how to convert json object to array in react native?

Example of to convert json object to array in react native with step by step guide.

June 19th, 2022 · 1 min read

how to convert string to int in react native?

Example of to convert string to int react native with step by step guide.

June 19th, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]