How to retrieve a string in ReactIntl 2.0 without using FormattedMessage

前端 未结 4 2019
南笙
南笙 2021-01-02 03:29

Please correct me if I am wrong, FormattedMessage in ReactIntl returns a string wrapped by span tags. In ReactIntl 1.2, we have the option to use this.getIntlMessage(\

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-02 03:57

    Ok, there is a work around for that. I can add ReactIntl as the context in the component like this:

    contextTypes: {
        intl: React.PropTypes.object.isRequired,
    },
    

    Then when trying to retrieve the string of the message and use it, for example in a placeholder, I can do this.

    
    

提交回复
热议问题