我正在使用react-router(0.13)和react-intl(1.2.0)。我在路线中有这个:
var i18n = {
locales: ['en-US']
};
var routes = (
<Route name='home' path='/' handler={App}>
</Route>
);
Router.run(routes, function (Handler) {
React.render(<Handler locales={i18n.locales} />, document.body);
});
这在App中:
var ReactIntl = require('react-intl');
var IntlMixin = ReactIntl.IntlMixin;
var FormattedRelative = ReactIntl.FormattedRelative;
var App = React.createClass({
mixins: [IntlMixin],
render: function() {
var postDate = Date.now() - (1000 * 60 * 60 * 24);
var foo = this.formatRelative(postDate); //this worked before updating to 1.2.0
return (
{foo}
<FormattedRelative value={postDate}/>
);
}
});
命令性调用(this.formatRelative)和formatRelative的组件使用都失败了:'消息必须以String或AST的形式提供。'
我做错了什么?