0

I have an array with key and values which I want to show in a list with on/off switch.

{
  "cCode1": "Unique code",
  "cCode2": "Brand Code",
  "cCode3": "Pattern Code",
  "cCode4": "Assortment Code",
  "cCode5": "Size Code",
  "cCode6": "COLOR Code",
  "cName1": "UniqueCode Name",
  "cName2": "Brand NAme",
  "cName3": "Pattern Name",
  "cName4": "Assortment Name",
  "cName5": "Size Name",
  "cName6": "COLOR Name",
}

This is something I want to achieve, also how to handle switch state. enter image description here

1 Answer 1

1
yourArray.map(item => {

return <View style={{flexDirection: 'row', height:  50}}>
        <Text style={{someStyle}}>{item.title}</Text>
        <Switch/>
   </View>
})

This is a pseudo Add the result of above array on ScrollView so that UI will be visible in all devices.

Sign up to request clarification or add additional context in comments.

3 Comments

this list is dynamic, i guess this method is for static array only. And there are around 50-60 keys, i just sent around 10 keys just for an idea
your list will be your array here. Doesn't matter the length of list same logic will work any length of array. My one more suggestion here. If your list if big then instead of scrollView use FlatList. This will save memory and improve performance.
I am using flatlist only but the type of array cannot be loaded in flatlist data directly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.