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;
|
lang: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SourceCode extends React.PureComponent<SourceCodeProps> {
|
export const SourceCode = (props: SourceCodeProps) => {
|
||||||
render() {
|
const { source, lang } = props;
|
||||||
const { source, lang } = this.props;
|
return <StyledPre dangerouslySetInnerHTML={{ __html: highlight(source, lang) }} />;
|
||||||
return <StyledPre dangerouslySetInnerHTML={{ __html: highlight(source, lang) }} />;
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class SourceCodeWithCopy extends React.Component<SourceCodeProps> {
|
export const SourceCodeWithCopy = (props: SourceCodeProps) => {
|
||||||
render() {
|
const { source, lang } = props;
|
||||||
return (
|
return (
|
||||||
<CopyButtonWrapper data={this.props.source}>
|
<CopyButtonWrapper data={source}>
|
||||||
{({ renderCopyButton }) => (
|
{({ renderCopyButton }) => (
|
||||||
<SampleControlsWrap>
|
<SampleControlsWrap>
|
||||||
<SampleControls>{renderCopyButton()}</SampleControls>
|
<SampleControls>{renderCopyButton()}</SampleControls>
|
||||||
<SourceCode lang={this.props.lang} source={this.props.source} />
|
<SourceCode lang={lang} source={source} />
|
||||||
</SampleControlsWrap>
|
</SampleControlsWrap>
|
||||||
)}
|
)}
|
||||||
</CopyButtonWrapper>
|
</CopyButtonWrapper>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user