【问题标题】:object are not valid as Reactchild in react-jsx-parser对象在 react-jsx-parser 中作为 Reactchild 无效
【发布时间】:2022-08-12 15:22:59
【问题描述】:

我想渲染我的 Html 字符串包含这个 {{somerton}},但是我收到这个错误,对象作为反应子无效

  • 唯一允许在 JSX 中直接渲染的对象是数组。
  • 我不想将其渲染为对象。实际上我想解析我的字符串,就像 \"<string>{{my_token}}</strong>\"

标签: html-parser


【解决方案1】:

我遇到了同样的问题,然后我用html-react-解析器喜欢:

import parse from 'html-react-parser';
parse(my string)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-13
    • 2018-05-27
    • 2021-10-17
    • 2017-05-27
    • 1970-01-01
    • 2021-09-27
    • 2017-02-09
    相关资源
    最近更新 更多