So I have an object like so,
Object{ 2017-08-01:Array(2), 2017-08-02:Array(1) }
I have used the following code, to iterate through it,
return Object.keys(this.state.visits).map(function(key, index){
console.log(key);
return (
<View style={{height: 40, flexDirection: 'row'}}>
<Text style={{marginLeft: 10,marginTop: 10, fontWeight:'500'}}>{key}</Text>
</View>
);
});
What happens is, this code, prints the 'key' perfectly in the console.log, but in the view, only the last date gets printed, and I also get an error in the console like so,
Warning: Each child in an array or iterator should have a unique "key" prop.
Check the render method of
filename. See https://facebook.github.io/react/docs/lists-and-keys.html#keys for more information.
What I'm trying to achieve is as follows,
+-------------------------------------------------------------+
| Date1 |
+-------------------------------------------------------------+
| Record 1 |
+-------------------------------------------------------------+
| Record 2 |
+-------------------------------------------------------------+
+-------------------------------------------------------------+
| Date 2 |
+-------------------------------------------------------------+
| Record 1 |
+-------------------------------------------------------------+
But I got stuck on the date part, so am not being able to proceed.