formatjs icon indicating copy to clipboard operation
formatjs copied to clipboard

Possible to call formatMessage in a utils file?

Open AndroidDoctorr opened this issue 9 years ago • 3 comments

If I have a utility file containing a set of exported functions, rather than a component with props, is there a way to use formatMessage here?

AndroidDoctorr avatar Aug 17 '17 22:08 AndroidDoctorr

You'll need to pass the format* functions as parameters if you want to reuse your react-intl settings

ghostd avatar Aug 18 '17 06:08 ghostd

Oh yeah, that makes sense. I think that will work.

AndroidDoctorr avatar Aug 18 '17 20:08 AndroidDoctorr

If you need more than the formatMessage methods (current locale...), pass the intl shape

If you think your issue is answered, please close the thread.

ghostd avatar Aug 19 '17 18:08 ghostd