Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react insert variable into string

import React from 'react';
import ReactDOM from 'react-dom';
const text = 'world';

const App = () => {
  return (
    <div>
	  {/*1. Using template literals and ${expression}*/}
      	{`Hello ${text}`}

	  {/*2. Concatenating variable and string*/}
 		{'Hello ' + text}
    </div>
  );
};

const root = document.querySelector('#root');
ReactDOM.render(<App />, root );
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery onchange get element 
Javascript :: what is the slice method in javascript 
Javascript :: spam system discord.js 
Javascript :: handle bar 
Javascript :: how to add class in javascript dynamically 
Javascript :: display unique id number in angular 
Javascript :: shell 
Javascript :: utc to est javascript 
Javascript :: angular two datepickers 
Javascript :: react native share link 
Javascript :: regex for international phone number 
Javascript :: message.channel.name.includes 
Javascript :: write files in Node.js 
Javascript :: js bind prototype arrow function 
Javascript :: async await nodejs 
Javascript :: how to perform transaction with sequelize 
Javascript :: how to check whether we are running on electron or browser 
Javascript :: javascript settimeout lambda function 
Javascript :: css using inline styles 
Javascript :: remove string from outside array javascript 
Javascript :: javascript line chart 
Javascript :: find the sum of an attribute in sequelize 
Javascript :: testing with jest 
Javascript :: javascript bind multiple arguments 
Javascript :: add class to new element javascript 
Javascript :: what does connect do in redux 
Javascript :: eval javascript 
Javascript :: remove element javascript 
Javascript :: js some 
Javascript :: vuetify use selected value 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =