最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How handle "missing message" error in react-intl? - Stack Overflow

programmeradmin3浏览0评论

I'm using react-intl version 2.4.0 and for some translations I receive "missing message" error in console. Is there any way to handle them without upgrading to v3?

<IntlProvider
        locale="ru"
        messages={localeData.ru}
      >
        <Layout>
          <Component {...props} />
        </Layout>
      </IntlProvider>

I'm using react-intl version 2.4.0 and for some translations I receive "missing message" error in console. Is there any way to handle them without upgrading to v3?

<IntlProvider
        locale="ru"
        messages={localeData.ru}
      >
        <Layout>
          <Component {...props} />
        </Layout>
      </IntlProvider>

Share Improve this question edited Jan 21, 2020 at 11:31 Yerlan Yeszhanov asked Dec 18, 2019 at 8:39 Yerlan YeszhanovYerlan Yeszhanov 2,43912 gold badges42 silver badges78 bronze badges 3
  • What do you mean by 'handle them'? – Brett DeWoody Commented Dec 18, 2019 at 8:44
  • Without upgrading to v3 it would be a little tricky. Had you happened to look at this comment github.com/formatjs/react-intl/issues/… – Sumit Surana Commented Dec 18, 2019 at 8:45
  • @BrettDeWoody do not show error in console – Yerlan Yeszhanov Commented Dec 18, 2019 at 8:46
Add a comment  | 

1 Answer 1

Reset to default 20

I had not read that issue on GH, but if you scroll to the bottom you'll see there is now an onError prop (as of v2.7.1) to provide a custom error handler.

   <IntlProvider onError={myCustomErrorFunction} />

Provide your own error handler (without a console.error) and the console error should go away.

发布评论

评论列表(0)

  1. 暂无评论