Home > Software engineering >  how to store different different multiple response in one variable in react native javascript
how to store different different multiple response in one variable in react native javascript

Time:11-23

I am getting response like this =

Object {
  "city": "Nanekarwadi",
  "country": "India",
  "district": null,
  "isoCountryCode": "IN",
  "name": "PRXX 37P",
  "postalCode": "410501",
  "region": "Maharashtra",
  "street": null,
  "subregion": "Pune",
  "timezone": null,
}

Now I want to show my subregion, postal code, region these all three in Text Input field in editable format. so How to do it. Now I am trying like this

setCompleteAdd(response)   or setCompleteAdd(respone.subreg, res.city, res.code)

and in text input like this

<TextInput
value={CompleteAdd}
/>

But I know this is not gonna work. so please help . thanks

CodePudding user response:

It depends on how do you want to show these three objects if there is any specific format you wanted to show your state. For e.g: Pune, Nanekarwadi, 410501

Then save it like this:

setCompleteAdd(`${response.subreg}, ${response.city}, ${response.code}`)

And show it to your value prop of TextInput like the same:

<TextInput
   value={CompleteAdd}
   onChangeText={ setCompleteAdd }
/>

Hope this works for you.

  • Related