I’m creating my first non-tutorial React Native app, and I want to use Moment to format dates in React Native.
My App.js looks like this:
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Moment from 'react-moment';
export default class App extends React.Component {
render() {
let now = new Date();
return (
<View style={styles.container}>
<Moment format="dddd">{now}</Moment>
<Moment format='MMMM Do YYYY'>{now}</Moment>
<Text>Today at a Glance</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
and when I run the app on my iPhone with the Expo app, I get the error Expected a component class, got [object Object].
I read at least eight StackOverflow posts, did a Google search, searched YouTube, and posted to StackOverflow but received no responses.
I want the first Moment to display the current day of the week, and the other Moment to display a date like October 9th, 2017.
What should I do instead?