Wt.N
Wt.N

Reputation: 1658

How to render variable in string in <Text> JSX tag in React Native

How to enable template string in React Native? My code doesn't work:

<Text>{`My name is ${name}`}</Text>

Upvotes: 3

Views: 10873

Answers (1)

Ajin Kabeer
Ajin Kabeer

Reputation: 2186

There is no need of adding template strings inside a <Text> component for adding strings in react-native. You can just use simple text and for variables, you can wrap it with curly braces.

<Text>My name is {name}</Text>

Upvotes: 10

Related Questions