1
  • I Need to Display Below the Array Data into Render Function :

  • I would Know how to loop the data and display it in Render.

[{ profileid: 1, enabled: 1, attachment: '', id: 233, topicid: 47, tstamp: 'January, 21 2016 15:06:31 +1100', body: 'to check orders' }, { profileid: 2, enabled: 1, attachment: '', id: 233, topicid: 47, tstamp: 'January, 21 2016 15:06:31 +1100', body: 'to check orders' } ]

2 Answers 2

1

I hope I help you

 class Parent extends  React.Component{
        constructor(props){
            super(props);
            this.state = {
                gists : []
            }
        }

        componentDidMount() {
            fetch('http://rest.......')
                .then(response => response.json())
                .then(gists => this.setState({ gists }))
        }


        render(){
             return (
                 <ul>
                     {this.state.gists.map(gist => (
                         <li key={gist.countryId}>{gist.name}</li>
                     ))}
                 </ul>
             )
        }
    }

Parent.propTypes = {
    data: React.PropTypes.array
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank You @zloctb
1

Here is an example.

import React from 'react'
import { View, Text } from 'react-native'
...
const data = [{
    profileid: 1,
    enabled: 1,
    attachment: '',
    id: 233,
    topicid: 47,
    tstamp: 'January, 21 2016 15:06:31 +1100',
    body: 'to check orders'
}, {
    profileid: 2,
    enabled: 1,
    attachment: '',
    id: 233,
    topicid: 47,
    tstamp: 'January, 21 2016 15:06:31 +1100',
    body: 'to check orders'
} ]
...
render() {

    return (
        <View>
            {data.map((dataItem) =>
                <View key={dataItem.profileid}>
                    <Text>{dataItem.profileId}</Text>
                    <Text>{dataItem.enabled}</Text>
                    <Text>{dataItem.attachment}</Text>
                    <Text>{dataItem.id}</Text>
                    <Text>{dataItem.topicid}</Text>
                    <Text>{dataItem.tstamp}</Text>
                    <Text>{dataItem.body}</Text>
                </View>
            )}
        </View>
    )

}

1 Comment

Thanks @Patrik Prevuznak

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.