-
-
Notifications
You must be signed in to change notification settings - Fork 136
Closed as not planned
Labels
questionFurther information is requestedFurther information is requested
Description
Question
In the example bellow I have a ugly hack to reconstitute a specific element to text after it has been parsed by React through html-react-parser
:
options = {
replace: ({ name, attribs, children, ...rest }) => {
if (name === 'a' && attribs.href && !attribs.target) {
return <Link to={attribs.href}>{domToReact(children)}</Link>
}
if (name === 'video') {
return <div dangerouslySetInnerHTML={{ __html: `
<video autoplay loop muted playsinline>
<source src="${children[1].attribs.src}" type="video/mp4" />
</video>
`}}/>
}
}
}
This is due to facebook/react#6544, facebook/react#10389
Is there a better way to do this, and hopefully access original html, or better yet skip some element from being passed to the library? I could not find an example on the doc or attributes on the replace arguments to help with doing this. innerHTML
for example is not accessible on the children elements.
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested