【问题标题】:FormattedHTMLMessage not working after package-update (looking for alternative/fix)FormattedHTMLMessage 在包更新后不起作用(寻找替代/修复)
【发布时间】:2020-04-30 13:16:12
【问题描述】:

我们最近更新了我们网站的 npm 包(react-intl 版本 4.5.1),我们正在使用 react-intl。问题是,我们使用了似乎不再工作的 FormattedHTMLMessage 组件。如果我现在访问该页面,文本中会显示带有类名的元素。

我们通过 props 显示文本:

import React from "react";
import {
    FormattedMessage as FM,
    FormattedHTMLMessage as FHM
} from "react-intl";

export default props => {

return(
    ...
    <p className="fs-18 white-space-pre-line">
        <FM id={props.descriptionKey} />
    </p>
    ...
    );
};

在 .json 文件中的文本如下所示:

textDescription: "Sometext <span class='font-tilde-bold h3'>Sometext</span> Sometext"

有什么好的选择吗?或者我们通常应该使用其他方法吗?

【问题讨论】:

    标签: javascript reactjs react-intl formatjs


    【解决方案1】:

    FormattedHTMLMessage 在版本 4 中被删除。

    您可以在upgrade guild v3 -> v4 中看到。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-30
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 2021-06-29
      • 1970-01-01
      相关资源
      最近更新 更多