0

我想用反应组件替换检测到的文本模式

export const detectHashTagPattern = (text) => {
  if (!text) return "";
  let pattern = /This is a follow-up to your previous request #[0-9]+/gi;
  let hashTagPattern = /#[0-9]+/;

  text = text.replace(pattern, (res) => {
    return res.replace(
      hashTagPattern,
      `<ReactComponent/>`
    );
  });

  return text;
};

呈现为<ReactComponent/>[object Object]

4

0 回答 0