Skip to content Skip to sidebar Skip to footer

Accessing Array Inside Array In Json React-native

Trying to perform autocomplete suggestion by reading JSON data. The format of JSON data is: locations: [ { 'Companyname': 'pqr', 'Topfiveproduct

Solution 1:

TopfiveproductsList is an array of objects, you can't just do TopfiveproductsList.prodName to get what you need. It looks like you need to use an array of strings so you would have to build it yourself:

<Autocomplete
    autoCapitalize="none"
    autoCorrect={false} 
    data={locations}
    defaultValue={query}
    onChangeText={text => this.setState({ query: text })}
    renderItem={({ Companyname, TopfiveproductsList }) => {
        const prodNames = TopfiveproductsList.map(item => item.prodNames);
        return <Text>{Companyname} {prodNames}</Text   }}
    />

Post a Comment for "Accessing Array Inside Array In Json React-native"