Question: Replace node type text by a React Component
josue-suarez-wt opened this issue · 2 comments
josue-suarez-wt commented
Question
Is it possible to replace a domNode type text by a React Component? For example
if (domNode.type === 'text') { return <Text field={{ ...fieldsContent, value: domNode.data }} style={{ color: 'red' }} />;
Keywords
html-react-parser
react component
text
remarkablemark commented
@josue-suarez-wt yes, this is possible and a valid use-case of this library. See README
josue-suarez-wt commented
Thanks for confirming! Seems that my issue was because of returning an array done via .map.
In that case, returning a fragment wrapping the array works fine!
const jsxFragments = [...].map(...);
return <>{jsxFragments}</>;