13

It's return error when i try this code

react-intl version 3.1.6 && react version 16.9

import { IntlProvider, FormattedMessage , addLocaleData} from 'react-intl';
Chi Bui
  • 506
  • 1
  • 5
  • 10

3 Answers3

16

I'm still investigating but it looks like addLocaleData was removed as a breaking change for v3.

https://formatjs.io/docs/react-intl/upgrade-guide-3x

This was a bit confusing for me too because a lot of the tutorials and guides out there still use addLocaleData.

oklas
  • 7,935
  • 2
  • 26
  • 42
Brian
  • 310
  • 4
  • 9
  • Hi Brian, any luck finding out any more info on addLocaleData being removed? – uidevthing Aug 20 '19 at 10:22
  • 1
    Hey, the reasons for why addLocaleData are written in the upgrade-guide linked in my original post. – Brian Aug 21 '19 at 22:31
  • 1
    the link is broken now. New link (2020-09-17): https://formatjs.io/docs/react-intl/upgrade-guide-3x/ – kca Sep 17 '20 at 07:46
2

The historical context is that react-intl was written back when Intl.PluralRules & Intl.RelativeTimeFormat did not exist. Fast forward to now, Intl.PluralRules is officially in the Intl JS spec, and Intl.RelativeTimeFormat is stage 3 so we've changed the strategy for locale-data to polyfills instead on browsers that don't have those APIs.

Long Ho
  • 599
  • 4
  • 15
0

Probably not the ideal solution but downgrading react-intl to ^2.8.0 is a quick and easy option.

Darryl Mendonez
  • 1,081
  • 1
  • 15
  • 27