From ceeb8df1dda815f51e3b81654795da2e7c07123d Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Fri, 23 Jun 2023 12:01:33 +0200 Subject: [PATCH] refactor: convert to functional component --- src/components/RichText/parser/Parser.js | 30 +++++++++--------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/components/RichText/parser/Parser.js b/src/components/RichText/parser/Parser.js index a96062f73..50a98039d 100644 --- a/src/components/RichText/parser/Parser.js +++ b/src/components/RichText/parser/Parser.js @@ -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 ? ( -

- ) : null - } + return children ? ( +

+ ) : null } Parser.defaultProps = {