Paul Berkers
Paul Berkers

Reputation: 15

React Native parameters inside image uri

I want to change the values of the following link and make it dynamic. So I want to make those hardcoded zipcodes to dynamic so I can do which zipcode I want.

In the following I want to be able to change 5611DE dynamically.

<Image
    source={{ uri: 'https://openmapquestapi.com/staticmap/v5/map?center=eindhoven,5611DE,kerkstraat+7&locations=eindhoven,5611DE,...
/>

I want to make those hardcoded zipcodes to dynamic so I can do which zipcode I want

Upvotes: 0

Views: 187

Answers (1)

Snehal
Snehal

Reputation: 141

You can store your zip code in a variable like var zip; and then add that 'zip' variable in that image url instead of static zip codes as follows:

source={{uri: `https://ope...map?center=eindhoven,${zip},kerk...hoven${zip},...`}}

so basically, you can write a string between `` this back tick character and add ${varialeName} whenever you want to add a variable in between the string.

Upvotes: 1

Related Questions