I need to add formattedMessages, on a method on a React class.
We normally use injectIntl with a HOC and it works, but I am on a React class, and i've tried many things but still get the error:
Messages must be statically evaluate-able for extraction
How do i use a formattedMessage in a class?
getDisplayText() {
const { placeholder, value } = this.props;
if (!value || value.length === 0) {
return <div>{placeholder}</div>;
}
const messages = defineMessages({
locations: {
id: value.length > 1 ? 'SelectInputGrouped.locationsSelected' : 'SelectInputGrouped.oneLocationSelected',
defaultMessage: '{num} location selected',
values: { num: value.length },
},
});
return (
<div>
<FormattedMessage {...messages.locations} />
</div>
);
}