You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.
Hi ,
I want to put data from Parse in listview. I try this: constructor(props) { super(props); const dataSource = new ListView.DataSource({ rowHasChanged: (row1, row2) => row1 !== row2, }); this.state = { dataSource: dataSource, } }
then , i create those 3 functions:
**Function renderItem : _renderItem(task) { return ( <ListItem task={task} /> ); }
**Function listenForTasks: listenForTasks( ) { Parse.initialize("APPID"); Parse.serverURL = 'URL'; var GameScore = Parse.Object.extend("Category"); var gameScore = new GameScore(); var tasks = []; var ds = this.state.dataSource; var query = new Parse.Query(gameScore); query.find({ success: function(results) { for (var i = 0; i < results.length; i++) { tasks.push({ name: results[i].get("name"), _key: results[i].get("objectId") }); } this.setState({ dataSource: ds.cloneWithRows(tasks.slice()) }); }, error: function(error) { alert( mystate ); }, })
**Function componentDidMount componentDidMount() { this.listenForTasks( ); }
Then , i create my listView : <ScrollView style={{flex: 1}}> <ListView enableEmptySections={true} dataSource={this.state.dataSource} renderRow={this._renderItem.bind()} /> <Button onPress={this.listenForTasks.bind(this)}> <Text> Here </Text> </Button> </ScrollView>
I create a file ListItem
`export default class ListItem extends Component {
render(){
return(
{this.props.task.name}
)}
}`
But nothing is displayed.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi ,
I want to put data from Parse in listview. I try this:
constructor(props) { super(props); const dataSource = new ListView.DataSource({ rowHasChanged: (row1, row2) => row1 !== row2, }); this.state = { dataSource: dataSource, } }
then , i create those 3 functions:
**Function renderItem :
_renderItem(task) { return ( <ListItem task={task} /> ); }
**Function listenForTasks:
listenForTasks( ) { Parse.initialize("APPID"); Parse.serverURL = 'URL'; var GameScore = Parse.Object.extend("Category"); var gameScore = new GameScore(); var tasks = []; var ds = this.state.dataSource; var query = new Parse.Query(gameScore); query.find({ success: function(results) { for (var i = 0; i < results.length; i++) { tasks.push({ name: results[i].get("name"), _key: results[i].get("objectId") }); } this.setState({ dataSource: ds.cloneWithRows(tasks.slice()) }); }, error: function(error) { alert( mystate ); }, })
**Function componentDidMount
componentDidMount() { this.listenForTasks( ); }
Then , i create my listView :
<ScrollView style={{flex: 1}}> <ListView enableEmptySections={true} dataSource={this.state.dataSource} renderRow={this._renderItem.bind()} /> <Button onPress={this.listenForTasks.bind(this)}> <Text> Here </Text> </Button> </ScrollView>
I create a file ListItem
{this.props.task.name}`export default class ListItem extends Component {
render(){
return(
}`
But nothing is displayed.
The text was updated successfully, but these errors were encountered: