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
  • 450
  • 1
  • 4
  • 9

2 Answers2

15

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
  • 6,279
  • 2
  • 21
  • 36
Brian
  • 300
  • 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
1

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
  • 541
  • 4
  • 15