I've been working on creating a react-native ListView that displays the results fetched from Realm. I've been following tutorials on how to use react-native's ListView with Realm, but I keep running into the same issue.
Whenever I try to render the data, I get an error message stating:
Objects are not valid as a React child (found: [object Results]). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of 'Text'.
Based on my understanding of the Realm documentation and other resources, the Results object is supposed to act like a standard JavaScript list and should be accepted by the cloneWithRows method.
If anyone can provide some guidance on what I might be doing incorrectly or how to resolve this issue, I would greatly appreciate it.
P.S. I've tried using both react-native's ListView and Realm's ListView, but the problem persists.
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
Navigator,
TouchableHighlight,
TouchableOpacity,
//ListView,
} from 'react-native';
import { ListView } from 'realm/react-native';
import realm from './myrealm'
class contextview extends Component {
getState() {
console.log("getInitialState");
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
let pictures = [ realm.objects('picture').filtered('new == true') ];
console.log("pictures: " + pictures);
return {
//dataSource: ds.cloneWithRows(['row 1', 'row 2', 'row 3']),
dataSource: ds.cloneWithRows(pictures)
};
}
constructor(props)
{
super(props);
this.state = this.getState();
this.bindMethods();
}
render() {
return (
<ListView
dataSource={this.state.dataSource}
renderRow={(rowData) => <Text>{rowData}</Text>}
/>
);
}
}