Closed grantCHG closed 2 years ago
It's by design because react-intl-universal could be used in non-react component.
react-intl-universal
If you declare constants before intl.init(...), the intl.get method is executed when js script loaded. So it can't get the locale data.
intl.init(...)
intl.get
const myData = { label: intl.get('key1').d('message'), value: 1 } const MyComp = () => { return <div>{myData.label}</div> }
Changing constants to function will work:
const myData = { get label() {return intl.get('key1').d('message')} value: 1 } const MyComp = () => { return <div>{myData.label}</div> }
It's by design because
react-intl-universal
could be used in non-react component.If you declare constants before
intl.init(...)
, theintl.get
method is executed when js script loaded. So it can't get the locale data.Changing constants to function will work: