我已经收窄下来发现,只有当我尝试作为<Moment />
描述传递React-Moment documentation组件发生错误。到目前为止,我还没有发现针对该包的任何解释,并希望有人在那里已经有过类似的问题!
该文档拼出这样的用法:
import Moment from 'react-moment';
// then within the class component:
return (
const dateToFormat = '1976-04-19T12:59-0500';
<Moment>{dateToFormat}</Moment>
);
我想借此原始日期字符串是这样的:
<Text>Created {this.props.postDate}</Text>
这正是如此存储:"postDate": "2019-01-31T04:13:31.224Z"
但到目前为止,我随时添加<Moment>{this.props.postDate}</Moment>
,不管是外部的或现有的<Text />
块,我得到的红色内:
这是在文档中:
https://github.com/headzoo/react-moment#usage-with-react-native
<Moment element={Text}>{dateToFormat}</Moment>