From d85e55e04f908311e2fd39c111ac4151646b5eea Mon Sep 17 00:00:00 2001 From: Alex Varchuk Date: Tue, 5 Jul 2022 13:01:44 +0300 Subject: [PATCH] chore: refactor class components to functional --- src/components/SourceCode/SourceCode.tsx | 37 +++++++++++------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/components/SourceCode/SourceCode.tsx b/src/components/SourceCode/SourceCode.tsx index 12a580db..9a6e352f 100644 --- a/src/components/SourceCode/SourceCode.tsx +++ b/src/components/SourceCode/SourceCode.tsx @@ -9,24 +9,21 @@ export interface SourceCodeProps { lang: string; } -export class SourceCode extends React.PureComponent { - render() { - const { source, lang } = this.props; - return ; - } -} +export const SourceCode = (props: SourceCodeProps) => { + const { source, lang } = props; + return ; +}; -export class SourceCodeWithCopy extends React.Component { - render() { - return ( - - {({ renderCopyButton }) => ( - - {renderCopyButton()} - - - )} - - ); - } -} +export const SourceCodeWithCopy = (props: SourceCodeProps) => { + const { source, lang } = props; + return ( + + {({ renderCopyButton }) => ( + + {renderCopyButton()} + + + )} + + ); +};