mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-04 12:20:19 +03:00
chore: refactor class components to functional
This commit is contained in:
parent
1c0b31415e
commit
d85e55e04f
|
@ -9,24 +9,21 @@ export interface SourceCodeProps {
|
|||
lang: string;
|
||||
}
|
||||
|
||||
export class SourceCode extends React.PureComponent<SourceCodeProps> {
|
||||
render() {
|
||||
const { source, lang } = this.props;
|
||||
return <StyledPre dangerouslySetInnerHTML={{ __html: highlight(source, lang) }} />;
|
||||
}
|
||||
}
|
||||
export const SourceCode = (props: SourceCodeProps) => {
|
||||
const { source, lang } = props;
|
||||
return <StyledPre dangerouslySetInnerHTML={{ __html: highlight(source, lang) }} />;
|
||||
};
|
||||
|
||||
export class SourceCodeWithCopy extends React.Component<SourceCodeProps> {
|
||||
render() {
|
||||
return (
|
||||
<CopyButtonWrapper data={this.props.source}>
|
||||
{({ renderCopyButton }) => (
|
||||
<SampleControlsWrap>
|
||||
<SampleControls>{renderCopyButton()}</SampleControls>
|
||||
<SourceCode lang={this.props.lang} source={this.props.source} />
|
||||
</SampleControlsWrap>
|
||||
)}
|
||||
</CopyButtonWrapper>
|
||||
);
|
||||
}
|
||||
}
|
||||
export const SourceCodeWithCopy = (props: SourceCodeProps) => {
|
||||
const { source, lang } = props;
|
||||
return (
|
||||
<CopyButtonWrapper data={source}>
|
||||
{({ renderCopyButton }) => (
|
||||
<SampleControlsWrap>
|
||||
<SampleControls>{renderCopyButton()}</SampleControls>
|
||||
<SourceCode lang={lang} source={source} />
|
||||
</SampleControlsWrap>
|
||||
)}
|
||||
</CopyButtonWrapper>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user