Skip to content

Commit

Permalink
refactor: convert to functional component
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Jun 23, 2023
1 parent 1310140 commit ceeb8df
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions src/components/RichText/parser/Parser.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import React, { useMemo } from 'react'
import MdParserClass from './MdParser.js'

class Parser extends Component {
constructor(props) {
super(props)
const Parser = ({ children, style }) => {
const MdParser = useMemo(() => new MdParserClass(), [])

this.MdParser = new MdParserClass()
}

render() {
const { children, style } = this.props

return children ? (
<p
style={style}
dangerouslySetInnerHTML={{
__html: this.MdParser.render(children),
}}
/>
) : null
}
return children ? (
<p
style={style}
dangerouslySetInnerHTML={{
__html: MdParser.render(children),
}}
/>
) : null
}

Parser.defaultProps = {
Expand Down

0 comments on commit ceeb8df

Please sign in to comment.