一起使用react-autolink+react-emoji(报错r.split)

Use react-autolink+react-emoji together (give me error r.split)

我是 React 新手...我正在尝试将 react-autolink 组件与 react-emoji 组件一起使用。

问题是当我这样做时:

{@autolink(@emojify(@props.message.body))}

它给我这个错误:Uncaught TypeError: r.split is not a function

为什么?相反,如果我只使用:

@emojify(@props.message.body)

@autolink(@props.message.body)

有效...

有什么建议吗?

您需要遍历 React 元素数组并自动链接字符串(尚未转换的文本)。

@autolink(@props.message.body).map(el => {
  if( typeof el === "string" ) return @emojify(el); else return el;
});