preact-markup icon indicating copy to clipboard operation
preact-markup copied to clipboard

[Question] Markup component for React?

Open jschlieber opened this issue 9 years ago • 4 comments

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!

jschlieber avatar Jan 16 '17 10:01 jschlieber

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
)

developit avatar Jan 16 '17 20:01 developit

Thanks, will open a PR when I have time.

jschlieber avatar Jan 17 '17 10:01 jschlieber

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.

robinvdvleuten avatar Aug 03 '18 07:08 robinvdvleuten

And React's type is read-only 😅

robinvdvleuten avatar Aug 03 '18 07:08 robinvdvleuten