[Question] Markup component for React?
Is there a React component that does a similar or even the same thing like preact-markup? Or is it possible to use preact-markup with React somehow? I don't want to fully switch to Preact right now, so this is not an option.
Thanks in advance!
This library had originally been designed to work with either Preact or React, but the use of render arguments makes it Preact-specific. I'd be open to a PR to fix that. If fixed, you'd be able to do this
import React from 'react'
import ReactDOM from 'react-dom'
import Markup from 'preact-markup'
// tell Markup to use React VDOM elements
Markup.setReviver(React.createElement)
ReactDOM.render(
<Markup markup="<strong>hello</strong>" />,
document.body
)
Thanks, will open a PR when I have time.
I was looking into this as well. And one thing I ran into is the difference between h() and React.createElement(); Preact exposes a nodeName attribute and React exposes a type.
And React's type is read-only 😅