[React Intl] Get locale value from intl injector

Get 'injectIntl' from  'react-intl', it is a high order componet.

We need to wrap our component into 'injectIntl':

import { injectIntl, FormattedMessage, FormattedHTMLMessage, FormattedRelative , FormattedTime, FormattedNumber } from 'react-intl';

....

export default injectIntl(BookDetail);

It will inject 'intl' prop into our component, we can get 'locale' out of it:

const BookDetail = ({match, intl}) => {
 const {locale} = intl;   
 ....
}
原文地址:https://www.cnblogs.com/Answer1215/p/7265678.html