Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

cloneWithRows can't work with array #187

Open
sihemhssine opened this issue Aug 2, 2017 · 0 comments
Open

cloneWithRows can't work with array #187

sihemhssine opened this issue Aug 2, 2017 · 0 comments

Comments

@sihemhssine
Copy link

sihemhssine commented Aug 2, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant