Issue
I try to display the contents of hours but I get an error that is not clear to me because it just a date object.
What is the correct way to solve the following error :
״Objects are not valid as a React child (found: [object Date]). If you meant to render a collection of children, use an array instead״
hours = 2022-08-31T05:23:14.997Z
<Text>{hours}</Text>
Solution
Like this
let hours = new Date('2022-08-31T05:23:14.997Z')
return (
<View style={styles.container}>
<Text>{hours.getHours() + ':' + hours.getMinutes() + ':' + hours.getSeconds()}</Text>
</View>
);
Answered By - AbdulAzeem
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.