Skip to content
This repository has been archived by the owner on Aug 7, 2019. It is now read-only.

Latest commit

 

History

History
32 lines (29 loc) · 1.04 KB

react-intl-corner-cases.md

File metadata and controls

32 lines (29 loc) · 1.04 KB

React Intl Corner Cases

Examples about how to handle corner cases especially when you're using libraries like redux and so on.

  • use defineMessages with intl.formatMessage()
    const messages = defineMessages({
      placeholder: {
        id: 'OperatorSearchInput.placeholder',
        defaultMessage: '请选择人员',
      },
      notFoundContent: {
        id: 'OperatorSearchInput.notFoundContent',
        defaultMessage: '未找到匹配人员',
      },
      searchPlaceholder: {
        id: 'OperatorSearchInput.searchPlaceholder',
        defaultMessage: '输入关键词',
      },
    });
    
    ...
    <Select
          showSearch
          placeholder={intl.formatMessage(messages.placeholder)}
          notFoundContent={intl.formatMessage(messages.notFoundContent)}
          searchPlaceholder={intl.formatMessage(messages.searchPlaceholder)}
      ...
  • react-intl usage inside actions or maybe redux-sagas(somewhere you can't directly access the react-intl's apis)
  • react-intl usage with antd/rc-form form validation
  • react-intl usage with Enums